5. Given a checkerboard $n \times n$. A rook moves according to standard chess rules (i.e., in one move, the rook can be moved to a cell in the same row or the same column). For which $n$ is it possible to visit all cells of the board exactly once, if immediately after a horizontal move of the rook, a vertical move must follow and vice versa. If the rook is initially in a given cell or ends its route in it, the cell is considered visited. The initial cell of the rook can be chosen.
Answer: $n$ - even

Solution. Let $n$ be odd. Choose a column in which the rook neither started nor ended its route. Consider the first visit of the rook to this column, which was along a row. Therefore, the next move was along a column, and the rook visited a cell in the same column and then left it. Similarly, on the next visit, the rook visited two new cells in this column, and so on. Consequently, the rook could visit only an even number of cells in this column. Contradiction.

Example of board traversal $n \times n$ for even $n$:

| 1 | 4 | 5 | $\cdots$ | $\cdots$ | $2 n-4$ | $2 n-3$ | $n^{2}$ |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 2 | 3 | 6 | $\cdots$ | $\cdots$ | $2 n-5$ | $2 n-2$ | $2 n-1$ |
| $4 n-3$ | $4 n-4$ | $4 n-7$ | $\cdots$ | $\cdots$ | $2 n+4$ | $2 n+1$ | $2 n$ |
| $4 n-2$ | $4 n-5$ | $4 n-6$ | $\cdots$ | $\cdots$ | $2 n+3$ | $2 n+2$ | $4 n-1$ |
| $6 n-3$ | $6 n-4$ | $6 n-7$ | $\cdots$ | $\cdots$ | $4 n+4$ | $4 n+1$ | $4 n$ |
| $6 n-2$ | $6 n-5$ | $6 n-6$ | $\cdots$ | $\cdots$ | $4 n+3$ | $4 n+2$ | $6 n-1$ |
| $\cdots$ | $\cdots$ | $\cdots$ | $\cdots$ | $\cdots$ | $\cdots$ | $\cdots$ | $\cdots$ |
| $n^{2}-3$ | $n^{2}-4$ | $n^{2}-7$ | $\cdots$ | $\cdots$ | $n^{2}-2 n+4$ | $n^{2}-2 n+1$ | $n^{2}-2 n$ |
| $n^{2}-2$ | $n^{2}-5$ | $n^{2}-6$ | $\cdots$ | $\cdots$ | $n^{2}-2 n+3$ | $n^{2}-2 n+2$ | $n^{2}-1$ |