A = input() B = input() nums = '0123456789' def check(s): for ss in s: if ss in nums: continue else: return False # leading-zero 判定 if len(str(int(s))) != len(s): return False # 大きさ判定 return 0 <= int(s) <= 12345 if check(A) and check(B): print('OK') else: print('NG')