4. (a) Determine all pairs $(x, y)$ of (real) numbers with $0<x<1$ and $0<y<1$ for which $x+3 y$ and $3 x+y$ are both integers. An example of such a pair is $(x, y)=\left(\frac{3}{8}, \frac{7}{8}\right)$, because $x+3 y=\frac{3}{8}+\frac{21}{8}=\frac{24}{8}=3$ and $3 x+y=\frac{9}{8}+\frac{7}{8}=\frac{16}{8}=2$.

(b) Find the integer $m \geqslant 2$ for which there are exactly 119 pairs $(x, y)$ with $0<x<1$ and $0<y<1$ for which $x+m y$ and $m x+y$ are both integers.

Note: if $u \neq v$, then $(u, v)$ and $(v, u)$ are different pairs.
4. (a) Suppose $(x, y)$ is such a pair and consider the integers $a=x+3 y$ and $b=3 x+y$. Since $0<x, y<1$, it follows that $0<a, b<4$, or rather $1 \leqslant a, b \leqslant 3$.

Now, conversely, let $a$ and $b$ be two integers with $1 \leqslant a, b \leqslant 3$. There is exactly one pair of numbers $(x, y)$ for which $a=x+3 y$ and $b=3 x+y$. Indeed, combining the two equations gives $3 b-a=3(3 x+y)-(x+3 y)=8 x$ and $3 a-b=8 y$, or rather $x=(3 b-a) / 8$ and $y=(3 a-b) / 8$ (and these $x$ and $y$ do indeed satisfy the two equations). Substituting $1,2,3$ for $a$ and $b$ gives nine pairs $(x, y)$:

$$
\left(\frac{2}{8}, \frac{2}{8}\right),\left(\frac{5}{8}, \frac{1}{8}\right),\left(\frac{8}{8}, \frac{0}{8}\right), \quad\left(\frac{1}{8}, \frac{5}{8}\right),\left(\frac{4}{8}, \frac{4}{8}\right),\left(\frac{7}{8}, \frac{3}{8}\right), \quad\left(\frac{0}{8}, \frac{8}{8}\right),\left(\frac{3}{8}, \frac{7}{8}\right),\left(\frac{6}{8}, \frac{6}{8}\right).
$$

Due to the requirement that $0<x, y<1$, the two possibilities $(x, y)=\left(\frac{8}{8}, \frac{0}{8}\right),\left(\frac{0}{8}, \frac{8}{8}\right)$ must be excluded. The remaining 7 pairs are thus precisely the pairs asked for in the problem.

(b) Suppose $0<x, y<1$ and that $a=x+m y$ and $b=m x+y$ are integers. Then $1 \leqslant a, b \leqslant m$.

Given integers $a$ and $b$ with $1 \leqslant a, b \leqslant m$, there is exactly one pair $(x, y)$ for which $x+m y=a$ and $m x+y=b$, because combining the two equations gives: $m b-a=\left(m^{2}-1\right) x$ and $m a-b=\left(m^{2}-1\right) y$, or rather $x=(m b-a) /\left(m^{2}-1\right)$ and $y=(m a-b) /\left(m^{2}-1\right)$. These $x$ and $y$ indeed satisfy the two equations.

We now consider for which $a$ and $b$ the corresponding numbers $x$ and $y$ also satisfy $0<x, y<1$. From $1 \leqslant a, b \leqslant m$ it follows that $x \geqslant(m \cdot 1-m) /\left(m^{2}-1\right)=0$ and that $x \leqslant(m \cdot m-1) /\left(m^{2}-1\right)=$ 1. The cases $x=0$ and $x=1$ correspond precisely to $(a, b)=(m, 1)$ and $(a, b)=(1, m)$, respectively. Similarly, $0<y<1$ unless $(a, b)=(1, m)$ or $(a, b)=(m, 1)$. Of the $m^{2}$ possibilities for $(a, b)$, there are thus two without a solution. In total, this gives $m^{2}-2$ solutions $(x, y)$.

From $m^{2}-2=119$ it follows that $m=11$.