Hamster is playing a game on an $m \times n$ chessboard. He places a rook anywhere on the board and then moves it around with the restriction that every vertical move must be followed by a horizontal move and every horizontal move must be followed by a vertical move. For what values of $m,n$ is it possible for the rook to visit every square of the chessboard exactly once? A square is only considered visited if the rook was initially placed there or if it ended one of its moves on it.

[i]Brian Hamrick.[/i]
To determine for which values of \( m \) and \( n \) it is possible for the rook to visit every square of an \( m \times n \) chessboard exactly once, we need to analyze the movement constraints and the parity of the board dimensions.

1. **Movement Constraints**:
   - The rook alternates between vertical and horizontal moves.
   - This implies that the number of moves must be even for the rook to return to the same type of move (vertical or horizontal).

2. **Parity Analysis**:
   - If \( m \) and \( n \) are both even, the board has an even number of squares, and it is possible to cover all squares by alternating moves.
   - If \( m \) and \( n \) are both odd, the board has an odd number of squares, which makes it impossible to cover all squares because the rook would need to make an odd number of moves to cover an odd number of squares, but the alternating move constraint requires an even number of moves.
   - If one of \( m \) or \( n \) is even and the other is odd, the board has an even number of squares, and it is possible to cover all squares by alternating moves.

3. **Special Cases**:
   - For a \( 2 \times k \) board, where \( k \) is any integer, it is possible to cover all squares. The rook can move horizontally across the two rows, then move vertically to the next column, and repeat this pattern.
   - For larger boards where both dimensions are even, similar patterns can be constructed to ensure all squares are visited.

4. **Contradiction for More Than Two Odd Rows/Columns**:
   - If the board has more than two odd rows or columns, there will be at least one odd row or column that the rook neither starts nor finishes on. Each time the rook enters such a row or column, it covers two squares and leaves, resulting in an even number of squares being covered. This contradicts the requirement to cover an odd number of squares in that row or column.

Conclusion:
- The rook can visit every square exactly once if and only if at least one of \( m \) or \( n \) is even.

The final answer is \( \boxed{\text{The rook can visit every square exactly once if and only if at least one of } m \text{ or } n \text{ is even.}} \)