a, b = input(), input() def judge(n): if n.isdecimal(): if n == "0" or n[0] != "0": if 0 <= int(n) and int(n) <= 12345: return True return False print("OK" if judge(a) and judge(b) else "NG")