#P1254C. Point Ordering
Point Ordering
Description
This is an interactive problem.
Khanh has points on the Cartesian plane, denoted by . All points' coordinates are integers between and , inclusive. No three points are collinear. He says that these points are vertices of a convex polygon; in other words, there exists a permutation of integers from to such that the polygon is convex and vertices are listed in counter-clockwise order.
Khanh gives you the number , but hides the coordinates of his points. Your task is to guess the above permutation by asking multiple queries. In each query, you give Khanh integers , , , ; where either or ; and , , are three distinct indices from to , inclusive. In response, Khanh tells you:
- if , the area of the triangle multiplied by .
- if , the sign of the cross product of two vectors and .
Recall that the cross product of vector and vector is the integer . The sign of a number is it it is positive, and otherwise. It can be proven that the cross product obtained in the above queries can not be .
You can ask at most queries.
Please note that Khanh fixes the coordinates of his points and does not change it while answering your queries. You do not need to guess the coordinates. In your permutation , should be equal to and the indices of vertices should be listed in counter-clockwise order.
Interaction
You start the interaction by reading () — the number of vertices.
To ask a query, write integers , , , (, ) in a separate line. , and should be distinct.
Then read a single integer to get the answer to this query, as explained above. It can be proven that the answer of a query is always an integer.
When you find the permutation, write a number . Then write integers in the same line.
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
Hack format
To hack, use the following format:
The first line contains an integer () — the number of vertices.
The -th of the next lines contains two integers and () — the coordinate of the point .
Note
The image below shows the hidden polygon in the example:

The interaction in the example goes as below:
- Contestant reads .
- Contestant asks a query with , , , .
- Jury answers . The area of the triangle is . Note that the answer is two times the area of the triangle.
- Contestant asks a query with , , , .
- Jury answers . The cross product of and is . The sign of is .
- Contestant asks a query with , , , .
- Jury answers . The cross product of and is . The sign of is .
- Contestant says that the permutation is .