def f(s): try: spam = int(s) if len(str(spam)) != len(s): return False return 0 <= spam <= 12345 except Exception: return False A = input() B = input() if f(A) and f(B): print("OK") else: print("NG")