Description:
This is an interactive problem.
There is an $$$n$$$ by $$$n$$$ grid of conveyor belts, in positions $$$(1, 1)$$$ through $$$(n, n)$$$ of a coordinate plane. Every other square in the plane is empty. Each conveyor belt can be configured to move boxes up ('^'), down ('v'), left ('<'), or right ('>'). If a box moves onto an empty square, it stops moving.
However, one of the $$$n^2$$$ belts is stuck, and will always move boxes in the same direction, no matter how it is configured. Your goal is to perform a series of tests to determine which conveyor belt is stuck, and the direction in which it sends items.
To achieve this, you can perform up to $$$25$$$ tests. In each test, you assign a direction to all $$$n^2$$$ belts, place a box on top of one of them, and then turn all of the conveyors on.
One possible result of a query with $$$n=4$$$. In this case, the box starts at $$$(2, 2)$$$. If there were no stuck conveyor, it would end up at $$$(5, 4)$$$, but because of the stuck '>' conveyor at $$$(3, 3)$$$, it enters an infinite loop.
The conveyors move the box around too quickly for you to see, so the only information you receive from a test is whether the box eventually stopped moving, and if so, the coordinates of its final position.
Input Format:
None
Output Format:
None
Note:
For the first query of the first sample input, the box starts on $$$(2, 2)$$$ and enters an infinite loop containing rows $$$2$$$ and $$$3$$$. Because the stuck conveyor is in row $$$1$$$, it does not affect the outcome of the query.
For the second query of the first sample input, the conveyors are configured in the same way, but the box starts on $$$(1, 1)$$$. If there were no stuck conveyor, it would enter an infinite loop between $$$(1, 2)$$$ and $$$(1, 3)$$$. However, the stuck conveyor redirects it to $$$(0, 2)$$$.
After these two queries, the program is able to determine that the stuck conveyor is at $$$(1, 2)$$$ and directs items upward.
The query for the second sample input corresponds to the picture above. After asking the query, there are many possibilities for the stuck conveyor, but the program correctly guesses that it is at $$$(3, 3)$$$ and directs items to the right.