import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String A = reader.readLine(); String B = reader.readLine(); if (validate(A) && validate(B)) { System.out.println("OK"); } else { System.out.println("NG"); } } private static boolean validate(String s) { boolean isNumber = true; if (s.length() >= 2 && s.charAt(0) == '0' ) { isNumber = false; } else { for (int i = 0; i < s.length(); i++) { if (!Character.isDigit(s.charAt(i))) { isNumber = false; break; } } } int upperBound = 12345; int lowerBound = 0; if (isNumber) { int number = Integer.parseInt(s); if (lowerBound <= number && number <= upperBound) { return true; } else { return false; } } else { return false; } } }