A = input() B = input() try : a = int(A) if str(a) != A : print("NG") exit() elif (a < 0) or (a > 12345) : print("NG") exit() except Exception as error : print("NG") exit() try : b = int(B) if str(b) != B : print("NG") exit() elif (b < 0) or (b > 12345) : print("NG") exit() except Exception as error : print("NG") exit() print("OK")