a, b = input(), input() ans = 'NG' if a.isnumeric() and b.isnumeric(): if len(a) == len(list(str(int(a)))) and len(b) == len(list(str(int(b)))): if 0<=int(a)<=12345 and 0<=int(b)<=12345: ans = 'OK' print(ans)