import static java.lang.System.out; import java.util.Scanner; public class No446{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); String A=sc.nextLine(); String B=sc.nextLine(); int a=check(A); int b=check(B); if(a==1&&b==1){ out.println("OK"); }else{ out.println("NG"); } } private static int check(String s){ if(s.length()<1&&s.length()>5){return 0;} if(s.length()>1&&s.indexOf("0")==0){return 0;} try{int n=Integer.parseInt(s); if(n<=12345){return 1;} else{return 0;} }catch(Exception e){return 0;} } }