A = input() B = input() for r in A + B: if "0" <= r <= "9": True else: print("NG") exit(0) if (A != "0" and A[0] == "0") or (B != "0" and B[0] == "0"): print("NG") else: if 0 <= int(A) <= 12345 and 0 <= int(B) <= 12345: print("OK") else: print("NG")