def is_int(s): try: int(str(s)) return True except ValueError: return False def ok(n): return n >= 0 and n <= 12345 A = str(input()) B = str(input()) if is_int(A) and is_int(B): if A == str(int(A)) and B == str(int(B)) and ok(int(A)) and ok(int(B)): print("OK") else: print("NG") else: print("NG")