A = input() B = input() if A.isnumeric() and B.isnumeric(): if int(A) > 12345 or int(B) > 12345: print('NG') elif (A[0] == '0' and A != '0') or (B[0] == '0' and B != '0'): print('NG') else: print('OK') else: print('NG')