Problem

Source: Baltic Way 2002

Tags: induction, combinatorics proposed, combinatorics



The following solitaire game is played on an $m\times n$ rectangular board, $m,n\ge 2$, divided into unit squares. First, a rook is placed on some square. At each move, the rook can be moved an arbitrary number of squares horizontally or vertically, with the extra condition that each move has to be made in the $90^{\circ}$ clockwise direction compared to the previous one (e.g. after a move to the left, the next one has to be done upwards, the next one to the right etc). For which values of $m$ and $n$ is it possible that the rook visits every square of the board exactly once and returns to the first square? (The rook is considered to visit only those squares it stops on, and not the ones it steps over.)