12. Let's number from 1 to 28 the squares placed along the edge of a common $8 \times 8$ chessboard (see the figure on the side). Initially, a cubic die is placed on square 1 so that its bottom face exactly overlaps the entire square. We move the die along the squares as follows: the first move consists of rotating the die $90^{\circ}$ around the common side between square 1 and square 2 so that at the end the die is exactly on top of square 2. Similarly, we move the die from square 2 to 3, from 3 to 4, and so on, rotating the die each time around the common side between the square it is on and the next one. From square 28, we return to square 1, and after completing one round, we start over. How many moves are required at a minimum for the die to return to square 1 with the same top face it had at the beginning?

| 1 | 2 3 | 3 4 | 5 | 6 | 7 | 8 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 28 |  |  |  |  |  | 9 |
| 27 |  |  |  |  |  | 10 |
| 26 |  |  |  |  |  | 11 |
| 25 |  |  |  |  |  | 12 |
| 24 |  |  |  |  |  | 13 |
| 23 |  |  |  |  |  | 14 |
| 22 | 21 20 | 20 19 | 18 | 17 | 16 | 15 |
12. The answer is 84. Consider the orientation of the cube when it is at the corners of the chessboard: let's call $A, B, C, D$ the 4 corners, in the order in which the cube passes through them. If the cube occupies corner $A$ at some point with face $F$ facing upwards, at corners $B$ and $C$ $F$ is facing sideways, while at $D$ $F$ is again the top face. Therefore, the cube ends up with the same top face every 3 corners, which is every 21 moves. Since a complete path consists of 28 moves, the minimum number of moves required for the cube to return to the same corner with the same top face is $lcm(21,28)=84$.