The teacher did not recommend William because he was not a good student.
Who is "he"?
William