cho.sh
Notes
Loading...

Good Password

Time limit

2s

Memory limit

128 MB

Problem

Many encryption methods use prime numbers. A common approach is to choose two very large primes and use their product as a key, relying on the fact that factoring a large number is usually difficult.

If the chosen primes are large, their product is also large. However, a large key is not always hard to factor. A large number with a small factor can still be divided easily.

You are given a key value K and an integer L. Determine whether every non-1 factor that can appear in a factorization of K is at least L.

For example, K = 143 can be divided as 11 × 13. Therefore, when L = 11, the password is good. When L >= 12, it is not good because the factor 11 is smaller than L.

Given K and L, write a program that determines whether the password is good.

Input

The first line contains two integers K and L, separated by a space.

Output

If the password is good, print GOOD. Otherwise, print BAD followed by the smallest non-1 factor of K, separated by a space.

Constraints

  • 4 ≤ K ≤ 10^100
  • 2 ≤ L ≤ 1,000,000