def check(s): for c in s: if ord(c) < ord('0') or ord('9') < ord(c): return False if len(s) > 1 and s[0] == '0': return False if int(s) > 12345: return False return True if check(raw_input()) and check(raw_input()): print 'OK' else: print 'NG'