Let $a,b$ be two natural numbers. When we divide $a^2+b^2$ by $a+b$, we the the remainder $r$ and the quotient $q.$ Determine all pairs $(a, b)$ for which $q^2 + r = 1977.$
1. We start with the given equation: 
   \[
   a^2 + b^2 = (a + b)q + r
   \]
   where \( r \) is the remainder and \( q \) is the quotient when \( a^2 + b^2 \) is divided by \( a + b \).

2. We are given that:
   \[
   q^2 + r = 1977
   \]
   Solving for \( r \), we get:
   \[
   r = 1977 - q^2
   \]

3. Substituting \( r \) back into the original equation, we have:
   \[
   a^2 + b^2 = (a + b)q + 1977 - q^2
   \]
   Rearranging terms, we get a quadratic equation in \( q \):
   \[
   q^2 - (a + b)q + a^2 + b^2 - 1977 = 0
   \]

4. For \( q \) to be an integer, the discriminant of this quadratic equation must be a perfect square. The discriminant \( \Delta \) is given by:
   \[
   \Delta = (a + b)^2 - 4(a^2 + b^2 - 1977)
   \]
   Simplifying, we get:
   \[
   \Delta = (a + b)^2 - 4a^2 - 4b^2 + 7908 = 7908 + 2ab - 2(a^2 + b^2)
   \]

5. For \( \Delta \geq 0 \), we need:
   \[
   7908 + 2ab - 2(a^2 + b^2) \geq 0
   \]

6. Assuming without loss of generality that \( a \geq b \), it follows that:
   \[
   a + b \leq 88
   \]
   This is because if \( q \leq 43 \), then:
   \[
   r = 1977 - q^2 \geq 128
   \]
   which contradicts \( r < a + b \leq 88 \). Therefore, \( q \leq 44 \).

7. Given \( q^2 + r = 1977 \), we have:
   \[
   q = 44
   \]
   and:
   \[
   r = 1977 - 44^2 = 1977 - 1936 = 41
   \]

8. Substituting \( q = 44 \) and \( r = 41 \) back into the equation, we get:
   \[
   a^2 + b^2 = 44(a + b) + 41
   \]
   Rearranging, we have:
   \[
   a^2 + b^2 - 44(a + b) - 41 = 0
   \]
   Completing the square, we get:
   \[
   (a - 22)^2 + (b - 22)^2 = 1009
   \]

9. By Jacobi's two squares theorem, the only representation of 1009 as a sum of two squares is:
   \[
   1009 = 15^2 + 28^2
   \]

10. Therefore, the pairs \((a, b)\) that satisfy the equation are:
    \[
    (a, b) = (37, 50), (7, 50)
    \]
    and their permutations.

The final answer is \(\boxed{(a, b) = (37, 50), (7, 50)}\)