A = input() B = input() if len(A) >= 2: if A[0] == "0" and A[1] == "0": print("NG") exit() if len(B) >= 2: if B[0] == "0" and B[1] == "0": print("NG") exit() if A > "12345" or B > "12345": print("NG") exit() s = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] for i in range(len(A)): if A[i] not in s: print("NG") exit() for i in range(len(B)): if B[i] not in s: print("NG") exit() print("OK")