import java.io.*; public class No446{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String a = br.readLine(); String b = br.readLine(); char[] A = a.toCharArray(); char[] B = b.toCharArray(); if(check(a, A) && check(b, B)) System.out.println("OK"); else System.out.println("NG"); } public static boolean check(String a, char[] A){ boolean c = false; int count = 0; for(int i=0; i < A.length; i++) if(Character.isDigit(A[i])) count++; if(count == A.length){ int num = Integer.parseInt(a); if(num != 0 && a.startsWith("0")) return c; else if(num == 0 && a.startsWith("00")) return c; else if(0 <= num && num <= 12345 ) c = true; } return c; } }