def check(a): if any(not ai.isdigit() for ai in a): return False x = int(a) if (x and a[0]=="0"): return False if x==0 and len(a)>=2: return False return 0 <= x <= 12345 a = input() b = input() print("OK" if check(a) and check(b) else "NG")