A = input() B = input() def val(N): return any(N == str(i) for i in range(12346)) if val(A) and val(B): print('OK') else: print('NG')