a = str(input()) b = str(input()) def is_ok(s): if not s.isdecimal(): return False if len(s) >= 2 and s[0] == '0': return False if int(s) < 0 or int(s) > 12345: return False return True if is_ok(a) and is_ok(b): print('OK') else: print('NG')