A=raw_input() B=raw_input() def ABproblem(num): c=0 for a in num: if ord(a) < ord('0') or ord('9') < ord(a): return False elif c<4 and a=='0' and len(num)!=1: return False c+=1 if int(num)<=12345: return True if ABproblem(A) and ABproblem(B): print 'OK' else: print 'NG'