#yuki_446 def f(s): if len(s)>1 and s[0]=='0': return False if s.isdigit()==False: return False if int(s)>12345: return False return True a=raw_input() b=raw_input() if f(a) and f(b): print 'OK' else: print 'NG'