A = input() B = input() def valid(A): return any(str(i) == A for i in range(12345 + 1)) if valid(A) and valid(B): print("OK") else: print("NG")