6. (5 points) Numbers are marked on a chessboard (see Fig. 1). How many arrangements of 8 rooks are there such that no rook attacks another and the numbers on the squares occupied by the rooks include all numbers from 0 to 7?

\(\left(\begin{array}{llllllll}0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\ 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\ 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\ 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\end{array}\right)\)

Fig. 1.

Let's number the rows of the board from 1 to 8 from top to bottom. On the first row, the position of the rook can be chosen in 8 ways. For example, we choose the first cell with the number 0. On the second row, there are 7 options left. Six of them (cells from the second to the seventh) have the property that under them in the lower half of the board are numbers different from the number occupied by the first rook (in our case, 0), and one cell (the last one, with the number 7) is such that under it in the lower half stands the number occupied by the first rook (in our case, 0).

Consider the first group of 6 options and make an arbitrary choice (for example, the second cell with the number 1). After such a choice, it turns out that in the lower half of the board, positions with two different numbers are prohibited (in our case, 7 and 6). Therefore, positions with these numbers need to be chosen in the upper half of the board, and there are exactly 2 such options (in our case, the 7th and 8th cells in rows 3 and 4). After this choice, in the lower half of the board, there will be 4 columns with different numbers in the columns. That is, in the lower half, there are \(4! = 24\) options. Thus, we get \(8 \times 6 \times 2 \times 24\) options.

Consider the option of choosing a position on the second row when under the chosen cell in the lower half of the board stands the number chosen on the first row (in our case, the last cell with the number 7). After such a choice, in the third row, there are 6 options leading to a single option in the fourth row. After choosing options in the upper half of the board, in the lower half, there are again 4 free columns with four different numbers, i.e., 24 options. Thus, we get \(8 \times 1 \times 6 \times 24\) options.

In total, we get:

\(8 \times 6 \times 2 \times 24 + 8 \times 1 \times 6 \times 24 = 3456\).
Answer: 3456.

## Variant 2