import java.util.*; import java.util.regex.Pattern; import java.util.regex.Matcher; class Sample { public static void main(String[] args){ // スキャナーを定義 Scanner scanner = new Scanner(System.in); // 入力値を文字列として取得 String numberAStr = scanner.next(); String numberBStr = scanner.next(); // 正規表現を定義 Pattern pattern = Pattern.compile("^[0-9a-zA-Z]*$"); Matcher matcherA = pattern.matcher(numberAStr); Matcher matcherB = pattern.matcher(numberBStr); // 条件分岐 if(!matcherA.matches() || !matcherB.matches()){ System.out.println("NG"); } else if (!matcherA.matches() && !matcherB.matches()) { System.out.println("NG"); } else { if(numberAStr.indexOf("0")==1 || numberBStr.indexOf("0")==1){ System.out.println("NG"); } else if(numberAStr.indexOf("0")==1 && numberBStr.indexOf("0")==1){ System.out.println("NG"); } else { int numberAInt = Integer.parseInt(numberAStr); int numberBInt = Integer.parseInt(numberBStr); if(numberAInt > 12345 || numberBInt > 12345){ System.out.println("NG"); } else if (numberAInt > 12345 && numberBInt > 12345) { System.out.println("NG"); } else { System.out.println("OK"); } } } } }