# coding: utf-8 def valid(s): for c in s: o = ord(c) if not (ord("0") <= o and o <= ord("9")): return False if s[0] == "0" and len(s) > 1: return False i = int(s) if i > 12345: return False return True a = input().strip() b = input().strip() if valid(a) and valid(b): print("OK") else: print("NG")