from string import ascii_letters ng = set(ascii_letters) def check(S): if S == "0": return True if not set(S).isdisjoint(ng): return False if S[0] == "0": return False return int(S) <= 12345 ans = check(input()) & check(input()) if ans: print("OK") else: print("NG")