def main(): A = input() B = input() for n in (A, B): if not testcase(n): print('NG') exit() else: print('OK') def testcase(n): ret = False if n.isdecimal(): if int(n) <= 12345: if len(n) == 0 or n[0] != 0: ret = True return ret main()