def isok(S): if S[0] == "0" and len(S) != 1: return False cnt = 0 for i in range(10): cnt += S.count(str(i)) if cnt != len(S): return False if 0 <= int(S) <= 12345: return True else: return False A = input() B = input() if isok(A) and isok(B): print("OK") else: print("NG")