406580: GYM102443 K RotationAlmostSort
Description
A robot can execute a sequence of commands in an $$$n \times n$$$ square filled with numbers. The only type of command the robot can execute is:
Such command has the following effect: if the number in cell 1 is greater than the number in cell 2, then rotate counterclockwise a $$$2 \times 2$$$ square whose upper left corner is cell 3.
Each cell is described with a letter denoting its column and a digit denoting its row, concatenated without a space. The columns are marked from left to right staring with a, the rows are marked from top to bottom starting with 1.
If one of the cells in one of the commands doesn't fit into the $$$n \times n$$$ square, or if cell 3 is located in the bottommost row or the rightmost column, then the robot becomes broken.
a | b | c | |
1 | 2 | 3 | 9 |
2 | 5 | 6 | 6 |
3 | 1 | 7 | 9 |
a | b | c | |
1 | 2 | 9 | 6 |
2 | 5 | 3 | 6 |
3 | 1 | 7 | 9 |
After the execution of the entire program, the bottommost $$$n-2$$$ rows are written down concatenated in the order from top to bottom (the 3-rd row, the 4-th row, $$$\ldots$$$, the $$$n$$$-th row). The resulting sequence consisting of $$$n\cdot(n-2)$$$ numbers must be non-decreasing.
You are given an integer $$$n$$$. Output a program containing only commands of the described type, such that when a robot executes this program on any initial square with numbers, it doesn't become broken and makes the square satisfy the desired state.
InputThe first line contains a positive integer $$$n$$$ ($$$2 \le n \le 9$$$) — the size of the square with numbers.
OutputOutput a correct program. It must contain no more than $$$100\,000$$$ commands. Follow the output format shown in the example.
ExampleInput2Output
a2 > b2 ? a1 a2 > b2 ? a1 a2 > b2 ? a1Note
In order not to give a hint to the contestants, an example for $$$n \ge 3$$$ is not shown.
For $$$n = 2$$$ it is enough to obtain 0 non-decreasing rows, thus any syntactically correct program is a correct solution. But the shown program obtains not just 0, but 1 non-decreasing row in the bottom part of the square: it rotates the only $$$2 \times 2$$$ square counterclockwise until its bottom row becomes sorted non-decreasingly. It easy to prove that such situation will happen after 0, 1, 2 or 3 rotations.