But since 997 is prime, wouldn't Lagrange's theorem apply to show that there are ONLY 2 solutions?
What has Lagrange to do here? Since 997 is a prime there are only two solutions because any polynomial p(x) ( e.g., ) over a field can have at most different roots in some extension of the field.