Problem 5. Given is a table (see the drawing). It is allowed to rearrange the rows, as well as to rearrange the columns (in any order). How many different tables can be obtained in this way from the given table?

| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| 7 | 1 | 2 | 3 | 4 | 5 | 6 |
| 6 | 7 | 1 | 2 | 3 | 4 | 5 |
| 5 | 6 | 7 | 1 | 2 | 3 | 4 |
| 4 | 5 | 6 | 7 | 1 | 2 | 3 |
| 3 | 4 | 5 | 6 | 7 | 1 | 2 |
| 2 | 3 | 4 | 5 | 6 | 7 | 1 |
Solution. We will prove that the number of different tables is 7!.6!.

We observe that the numbers recorded in each row and column are different. Moreover, if 6 is added to each number in the first row and the remainder of the resulting sum when divided by 7 is written (with the agreement to write 7 instead of 0), the order of the numbers in the second row is obtained:

| first row | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|  | $\downarrow+6$ | $\downarrow+6$ | $\downarrow+6$ | $\downarrow+6$ | $\downarrow+6$ | $\downarrow+6$ | $\downarrow+6$ |
|  | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| second row | 7 | 1 | 2 | 3 | 4 | 5 | 6 |

The third row is obtained in the same way by adding 5 to the first, the fourth row by adding 4 to the first, and so on. When rows and columns are rearranged, this property is preserved in the following form: each row from the second to the seventh is obtained from the first by adding the same addend to the corresponding numbers in the first row and writing the remainder of the sum when divided by 7 (writing 7 instead of 0). The corresponding addend for each row is uniquely determined, for example, by the first number in the row. This means that the table is completely determined by the numbers in the top row and the left column.

By appropriately rearranging the columns, any permutation of the numbers from 1 to 7 in the top row can be obtained. The number of all such permutations is 7!. By rearranging the rows (from the second to the seventh), any permutation of the numbers in the remaining six fields of the left column can be obtained; the number of these permutations is 6!. Therefore, the table can be determined in $7!.6!$ ways.