Problem 5.7. Vasya wants to place the numbers from 1 to 6 (each one only once) in the squares such that the following condition is met: if two squares are connected, the number in the higher square is greater. How many ways are there to do this?

![](https://cdn.mathpix.com/cropped/2024_05_06_4984b677816e04f7f1c9g-12.jpg?height=357&width=418&top_left_y=548&top_left_x=518)
Answer: 12.

Solution. Let's color the squares in green and blue, as shown in the picture. The numbers in the squares of the same color will be arranged in descending order from top to bottom. For the red squares, we need to choose two numbers from 1 to 6: place the larger one in the upper square and the smaller one in the lower square. These can be any two numbers with the condition that the smaller of the two must be less than the second largest of the remaining numbers (which will go into the green squares and will be ordered there). In the picture, the number in square $A$ must be less than the number in square $B$. Let's consider the cases of what can be in square $M$.

![](https://cdn.mathpix.com/cropped/2024_05_06_4984b677816e04f7f1c9g-12.jpg?height=356&width=410&top_left_y=1334&top_left_x=526)