a = input() b = input() if a.isdigit() and b.isdigit(): flag = True if int(a) > 12345 or int(b) > 12345: flag = False if len(a) >= 2 and a[0] == "0": flag = False if len(b) >= 2 and b[0] == "0": flag = False if flag: print("OK") else: print("NG") else: print("NG")