IP
121.168.0.0
Created
03-28 09:58
1
import java.io.*;
2
import java.util.*;
3
4
class Main{
5
public static void main(String[] args)throws Exception{
6
BufferedReader I=new BufferedReader(new InputStreamReader(System.in));
7
BufferedWriter O=new BufferedWriter(new OutputStreamWriter(System.out));
8
9
StringTokenizer s=new StringTokenizer(I.readLine());
10
String p=s.nextToken();
11
int k=Integer.parseInt(s.nextToken());
12
13
StringBuilder a=new StringBuilder("GOOD");
14
15
if(p.length()<14){
16
ArrayList<Boolean> t=new ArrayList<>();
17
ArrayList<Long> r=new ArrayList<>();
18
for(int i=0;i<k;i++) t.add(true);
19
for(int i=2;i<k;i++){
20
if(t.get(i)){
21
for(int j=2*i;j<k;j+=i){
22
t.set(j,false);
23
}
24
}
25
} for(int i=2;i<k;i++){
26
if(t.get(i)) r.add((long)i);
27
}
28
29
//for(Boolean i:t) System.out.println(i);
30
//for(Long i:r) System.out.println(i);
31
32
long lp=Long.parseLong(p);
33
for(Long i:r){
34
for(Long j:r){
35
if(i*j==lp){
36
a.replace(0,a.length(),"BAD ").append(j);
37
break;
38
}
39
}
40
}
41
}
42
O.write(a+"\n");
43
O.flush();
44
}
45
}