a = input() b = input() input_list = [a, b] num_list = list(range(0, 10)) count = 0 for i in range(2): cur_str = input_list[i] judge_list = [int(c) in num_list for c in cur_str] if all(judge_list): if len(cur_str) == 1: count += 1 else: if cur_str[0] != '0' and int(cur_str) <= 12345: count += 1 if count == 2: print('OK') else: print('NG')