
Problem 4. Let $n \geq 2$ be fixed integer. At any point with integer coordinates $(i, j)$ we write $i+j$ modulo $n$. Find all pairs $(a ; b)$ of positive integers such that the rectangle with vertices $(0,0),(a, 0)$, $(a, b),(0, b)$ has the following properties:

1) the remainders $0,1, \ldots, n-1$ written in its interior points appear equal number of times;
2) the remainders $0,1, \ldots, n-1$ written on its boundary appear equal number of times.


Solution: Let $p_{i}$ and $s_{i}$ for $i=0,1, \ldots, n-1$ be the number of residues $i$ on the sides and in the interior of the rectangle respectively. If $a^{\prime}=a+k n$ for an integer $k$ then the corresponding numbers for $\left(a^{\prime}, b\right)$ are $p_{i}^{\prime}=p_{i}+2 k$ and $s_{i}^{\prime}=s_{i}+k(b-1)$.

Therefore if $(a, b)$ is a solution then $(a+k n, b)$ and by analogy $(a, b+\ln )$ are also solutions. Thus, wlog we may suppose that $1 \leq a, b \leq n$.

If $n=2$ then all possible values of $(a, b)$ are

$$
(a, b)=(1,1),(1,2),(2,1),(2,2)
$$

Pair $(2,2)$ is not a solution because there is unique interior point $\left(s_{0}=1, s_{1}=0\right)$ for the rectangle. The remaining three cases give solutions.

Therefore for $n=2$ solutions are all pairs $(a ; b)$ where either $a$ or $b$ is an odd number.

Let $n>2$ and suppose $(a, b)$ is a solution of the problem for
which $1 \leq a, b2)$ appears even number of times. Therefore $n$ divides $a+b$ and so $a+b=n$ or $a+b=2 n$. When $a+b=2 n$ we have that $a=b=n$. This pair is not a solution since the number of interior points is $(n-1)^{2}$ and is not divisible by $n$. It remains to consider the case $a+b=n$. If $a>1$ and $b>1$ then the rectangle has interior points. For any such point ( $i, j$ ) we have $02$ all solutions are $a=1+k n, b=n-1+l n$ and $a=n-1+k n, b=1+l n$, where $k, l=0,1,2, \ldots$.
