There are n-1 integers a1, a2, a3, ..., an-1, 1<=ai<=n. No two integers are the same, so exactly one integer from {1, 2, 3, ..., n} is missing.
Your task is to find out which one is missing.
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<=25). For each test case, first read an integer n (2<=n<=1000). Then issue one or more Ask commands followed by one Answer command.
Command | Description |
Ask i j | Returns the j-th bit of ai (1<=i<=n-1, 0<=j<=10). The bits are numbered 0, 1, ... from right to left. |
Answer x | Tells us that x is the missing integer. This command does not return anything. |
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).
For each test case, you can issue at most 2222 Ask commands, otherwise you'll get Protocol Limit Exceeded (PLE).
1 4 Ask 1 0 0 Ask 1 1 1 Ask 2 2 1 Ask 3 0 1 Ask 3 1 0 Answer 3
There is only one test case, a1=2, a2=4, a3=1.