Guess the Convex Polygon

There is a convex polygon P on the Cartesian plane satisfying the following conditions:

  1. The number of vertices n satisfies 3 ≤ n ≤ 20, and each vertex (x, y) satisfies |x|, |y| ≤ 10000. 2. (0,0) is strictly inside P.
  2. No two edges are collinear.
  3. No edges are parallel to x or y axis.
  4. Vertices have integer coordinates. Your task is to “guess” the polygon. Interaction Protocol Your program should read from standard input, and write to standard output. After printing each line to the standard output, you should flush the output, by calling fflush(stdout) or cout << flush in C/C++, flush(output) in Pascal and System.out.flush() in Java. Please read general instructions for interactive problems for more information. First, read the number of test cases T (1 ≤ T ≤ 100). For each test case, you can issue one or more ‘AskX’ and ‘AskY’ commands followed by one ‘Answer’ command. Command Description AskX x0 Returns c, the number of intersection points be- tween P and line x = x0, and their y coordinates, y1 y2...yc. AskY y0 Returns c, the number of intersection points be- tween P and line y = y0, and their x coordinates, x1 x2...xc. Answer n x1 y1 x2 y2 ... Tell us your answer. The vertices must be in counter- clockwise but you can start from any vertex. This command does not return anything. xn yn Each returned coordinate is given in “reduced fraction form” by two integer a and b, that means the coordinate is a/b. If your program violated any of these rules (bad format, invalid arguments etc), the server will exit immediately, and you will receive Protocol Violation (PV). Protocol Limit For each test case, you can issue at most 500 Ask (‘AskX’ or ‘AskY’) commands, otherwise you’ll get Protocol Limit Exceeded (PLE). Sample Explanation: Note that this interaction is only valid and does not mean the user program can really deduce the answer from the AskX/AskY commands before it.

2/2 Sample Interaction 1 121 2 -5 1 17 5 2 16 1 -6 1 0 AskX -6 AskX -5 AskY 2 AskY -20 Answer 5 8 -9 16 2 -1 9 -6 2 -5 -5