#abc269e. [abc269_e]Last Rook
[abc269_e]Last Rook
Problem Statement
This is an interactive task (where your program interacts with the judge's program via input and output).
We have an -by- chessboard and rooks. Below, the square at the -th row from the top and -th column from the left is denoted by .
Consider placing the rooks on squares of the chessboard. Here, you have to place the rooks so that all of the following conditions are satisfied.
- No row contains two or more rooks.
- No column contains two or more rooks.
Now, rooks are placed on the chessboard so that all of the above conditions are satisfied. You will choose a square that is not occupied by a rook and place a rook on that square. (It can be proved that there is at least one square on which a rook can be placed under the conditions.)
However, you cannot directly see which squares of the chessboard are occupied by a rook.
Instead, you may ask at most questions to the judge in the following manner.
- You choose integers , , , and such that $1 \\leq A \\leq B \\leq N, 1 \\leq C \\leq D \\leq N$, and ask the number of rooks in the rectangular region formed by the squares such that .
Find a square to place a rook.
Constraints
- is an integer.
Input and Output
This is an interactive task (where your program interacts with the judge's program via input and output).
First, receive the size of the chessboard, , from Standard Input.
Next, repeat asking a question until you find a square to place a rook.
A question should be printed to Standard Output in the following format:
The response will be given from Standard Input in the following format:
Here, is the response to the question, or -1
if the question is invalid or more than questions have been asked.
When the judge returns -1
, the submission is already regarded as incorrect. In this case, terminate the program immediately.
When you find a square to place a rook, let be that square and print an answer in the following format. Then, terminate the program immediately.
If there are multiple appropriate answers, any of them will be accepted.
Notes
- Each time you print something, end it with a newline and then flush Standard Output. Otherwise, you may get a TLE