2. Let $q$ be a positive rational number. Two ants are initially at the same point $X$ in the plane. In the $n$-th minute ($n=1,2, \ldots$), each of them chooses whether to move north, east, south, or west, and then travels a distance of $q^n$ meters. After an integer number of minutes, they are again at the same point in the plane (not necessarily point $X$), and the paths they have traveled are not entirely identical. Determine all possible values of the number $q$.

(United Kingdom)
2. Let $a_{n}$ denote the sum of the $x$- and $y$-coordinates of the first ant, and $b_{n}$ the sum of the coordinates of the second ant after $n$ minutes. From the problem statement, we have $\left|a_{n}-a_{n-1}\right|=\left|b_{n}-b_{n-1}\right|=q^{n}$, so $a_{n}=\epsilon_{1} q+\epsilon_{2} q^{2}+\cdots+\epsilon_{n} q^{n}$ and $b_{n}=\eta_{1} q+\eta_{2} q^{2}+\cdots+\eta_{n} q^{n}$ for some coefficients $\epsilon_{i}, \eta_{i} \in\{-1,1\}$. If the ants meet after $n$ minutes, then

$$
0=\frac{a_{n}-b_{n}}{2}=\frac{\epsilon_{1}-\eta_{1}}{2} q+\frac{\epsilon_{2}-\eta_{2}}{2} q^{2}+\cdots+\frac{\epsilon_{n}-\eta_{n}}{2} q^{n}=P(q)
$$

where the polynomial $P$ has all coefficients $\frac{\varepsilon_{i}-\eta_{i}}{2}$ as integers, in the set $\{-1,0,1\}$. Therefore, if $q=\frac{a}{b}(a, b \in \mathbb{N})$, then $a \mid 1$ and $b \mid 1$, so $q=1$ must hold.

The value $q=1$ is clearly possible, for example, if the first ant moves east then west, and the second ant moves north then south.

Second solution. Consider the positions of the ants $\alpha_{k}$ and $\beta_{k}$ after $k$ steps in the complex plane, assuming their starting point is at the origin and that the steps are parallel to the axes. We know that $\alpha_{k}-\alpha_{k-1}=a_{k} q^{k}$ and $\beta_{k}-\beta_{k-1}=b_{k} q^{k}$, where $a_{k}, b_{k} \in\{1,-1, i,-i\}$.

If $\alpha_{n}=\beta_{n}$ for some $n>0$, then

$$
\sum_{k=1}^{n}\left(a_{k}-b_{k}\right) q^{k}=0, \quad \text { where } \quad a_{k}-b_{k} \in\{0, \pm 1 \pm i, \pm 2, \pm 2 i\}
$$

Notice that the coefficient $a_{k}-b_{k}$ is always divisible by $1+i$ in the ring $\mathbb{Z}[i]$ : indeed,

$$
c_{k}=\frac{a_{k}-b_{k}}{1+i} \in\{0, \pm 1, \pm i, \pm 1 \pm i\}
$$

By canceling with $1+i$, we get $c_{1} q+c_{2} q^{2}+\cdots+c_{n} q^{n}=0$. Without loss of generality, assume that $c_{1}, c_{n} \neq 0$. If now $q=\frac{a}{b}(a, b \in \mathbb{N})$, then $a \mid c_{1}$ and $b \mid c_{n}$ in $\mathbb{Z}[i]$, which is only possible for $a=b=1$.