import re input_pattern = re.compile(r'^([1-9]\d*)$') def check(in_str): if len(in_str) < 1 or len(in_str) > 5: return False if in_str == '0': return True if input_pattern.match(in_str) is None: return False return int(in_str) <= 12345 A = input() B = input() if check(A) and check(B): print('OK') else: print('NG')