A = input() B = input() def isValid(A, B): if not isValidNumber(A): return False if not isValidNumber(B): return False return True def isValidNumber(A): if not isAllNumber(A): return False if A[0] == '0' and len(A) > 1: return False if int(A) > 12345: return False return True def isAllNumber(A): for c in A: if c not in '0123456789': return False return True if isValid(A, B): print('OK') else: print('NG')