Problem D

Statement
Copy Copied
Description:
This is an interactive problem.

Initially, there is an array $$$a = [1, 2, \ldots, n]$$$, where $$$n$$$ is an odd positive integer. The jury has selected $$$\frac{n-1}{2}$$$ disjoint pairs of elements, and then the elements in those pairs are swapped. For example, if $$$a=[1,2,3,4,5]$$$, and the pairs $$$1 \leftrightarrow 4$$$ and $$$3 \leftrightarrow 5$$$ are swapped, then the resulting array is $$$[4, 2, 5, 1, 3]$$$.

As a result of these swaps, exactly one element will not change position. You need to find this element.

To do this, you can ask several queries. In each query, you can pick two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$). In return, you will be given the elements of the subarray $$$[a_l, a_{l + 1}, \dots, a_r]$$$ sorted in increasing order.

Find the element which did not change position. You can make at most $$$\mathbf{15}$$$ queries.

The array $$$a$$$ is fixed before the interaction and does not change after your queries.

Recall that an array $$$b$$$ is a subarray of the array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input Format:
Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 500$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer $$$n$$$ ($$$3 \leq n < 10^4$$$; $$$n$$$ is odd) — the length of the array $$$a$$$.

After reading the first line of each test case, you should begin the interaction.

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^4$$$.

Output Format:
None

Note:
In the first test, the interaction proceeds as follows.

SolutionJuryExplanation$$$\texttt{2}$$$There are 2 test cases.$$$\texttt{5}$$$In the first test case, the hidden array is $$$[4,2,5,1,3]$$$, with length $$$5$$$.$$$\texttt{? 1 4}$$$$$$\texttt{1 2 4 5}$$$The solution requests the subarray $$$[4,2,5,1]$$$ in increasing order, and the jury responds with $$$[1,2,4,5]$$$.$$$\texttt{? 3 5}$$$$$$\texttt{1 3 5}$$$The solution requests the subarray $$$[5,1,3]$$$ in increasing order, and the jury responds with $$$[1,3,5]$$$.$$$\texttt{! 2}$$$The solution has somehow determined that $$$a_2=2$$$, and outputs it. Since the output is correct, the jury continues to the next test case.$$$\texttt{3}$$$In the second test case, the hidden array is $$$[1,3,2]$$$, with length $$$3$$$.$$$\texttt{? 1 1}$$$$$$\texttt{1}$$$The solution requests the number $$$[1]$$$ only, and the jury responds with $$$[1]$$$.$$$\texttt{! 1}$$$The solution has determined that $$$a_1=1$$$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit.

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.