def f(): try: n = input() assert n == str(int(n)) and int(n) < 12346 return 1 except: return 0 print(['NG', 'OK'][f() and f()])