A = input() B = input() if not A.isdigit() or not B.isdigit(): print("NG") elif not (0 <= int(A) <= 12345) or not (0 <= int(B) <= 12345): print("NG") elif (len(A) >= 2 and A[0] == "0") or (len(B) >= 2 and B[0] == "0"): print("NG") else: print("OK")