2. In how many ways can the numbers from 1 to 9 be arranged in a $3 \times 3$ table (each number appearing exactly once) such that in each column from top to bottom and in each row from left to right, the numbers are in increasing order? (20 points)
Solution: Let's number the cells of the table as shown in the figure. It is clear that the number 1 is in the upper left cell, and the number 9 is in the lower right cell.

| 1 | $a_{2}$ | $a_{3}$ |
| :---: | :---: | :---: |
| $a_{4}$ | $a_{5}$ | $a_{6}$ |
| $a_{7}$ | $a_{8}$ | 9 |

By the condition, $a_{5}>a_{2}, a_{5}>a_{4}, a_{5}<a_{6}, a_{5}<a_{8}$, so $4 \leq a_{5} \leq 6$. Let's consider the cases.

1) If $a_{5}=4$, then the numbers $a_{2}$ and $a_{4}$ are 2 and 3. There are 2 ways to arrange them. Now let's calculate the number of ways to choose the numbers $a_{3}$ and $a_{6}$. Any of the remaining pairs of numbers can be placed in their positions, and $a_{3}<a_{6}$, so the arrangement of each pair is unique. There are a total of $C_{4}^{2}=6$ such pairs. The remaining two numbers are arranged uniquely. In total, we have $2 \cdot 6=12$ ways of arranging.
2) If $a_{5}=6$, then the numbers $a_{6}$ and $a_{8}$ are 7 and 8, and the case is similar to the previous one. We get another 12 ways of arranging.
3) If $a_{5}=5$, then let's see which numbers can be in the cells $a_{3}$ and $a_{7}$. The numbers 2 and 8 cannot be placed in these cells, as these numbers must be neighbors of 1 and 9, respectively. If $a_{3}=3$, then $a_{2}=2$ and $a_{4}=4$. Any of the remaining numbers can be placed in the cell $a_{6}$ in 3 ways, and the remaining numbers are placed uniquely. The considered case is similar to the cases where $a_{3}=7, a_{7}=3$, and $a_{7}=7$ - in each we get 3 ways of arranging, but the cases where the numbers $a_{3}$ and $a_{7}$ are 3 and 7 were counted twice. There are a total of two such cases:

| 1 | 2 | 3 |
| :--- | :--- | :--- |
| 4 | 5 | 6 |
| 7 | 8 | 9 |


| 1 | 4 | 7 |
| :---: | :---: | :---: |
| 2 | 5 | 8 |
| 3 | 6 | 9 |

In the end, we get $3 \cdot 4-2=10$ ways.

If neither of the numbers in the cells $a_{3}$ and $a_{7}$ is 3 or 7, then the cells $a_{3}$ and $a_{7}$ can only contain the numbers 4 and 6 in any order. Then the cells $a_{2}$ and $a_{4}$ contain the numbers 2 and 3 in any order, and the cells $a_{6}$ and $a_{8}$ contain the numbers 7 and 8 in any order. In total, there are 8 ways of arranging.

All cases have been considered, and the desired number of ways is $24+10+8=42$.

Answer: 42