This is an interactive problem.
Background. On August 9, Sensei and Seia attend the Hidden Track. Blue Archive 3rd Anniversary Concert in Shanghai. Having arrived late, they are stuck in a remote corner, but Seia knows a hidden route to the second floor. Can you help poor Sensei find the way by following Seia's cryptic query rules?
For each test case, the interactor hides a permutation $$$p=(p_1,p_2,\ldots,p_n)$$$ of $$$\{0,1,\ldots,n-1\}$$$. When $$$n\ge 2$$$, it is guaranteed that $$$p_1 \lt p_n$$$. You may think of it as a hidden path, where $$$p_i$$$ and $$$p_{i+1}$$$ are connected by an edge for every $$$1\le i \lt n$$$. Your task is to find the hidden permutation using queries.
Let $$$k=\lceil\log_2 n\rceil$$$. In each query, you choose two integers $$$m$$$ and $$$v$$$, where $$$0\le m \lt 2^k$$$, and either $$$v=-1$$$ or $$$0\le v \lt n$$$. The integer $$$m$$$ determines a set of vertices: $$$$$$ B(m)= \left\{ x\mid 0\le x \lt n,\ \operatorname{popcount}(x\mathbin{\&}m)\text{ is odd} \right\} $$$$$$
Here, $$$\mathbin{\&}$$$ denotes the bitwise AND operation, and $$$\operatorname{popcount}(x)$$$ denotes the number of $$$1$$$-bits in the binary representation of $$$x$$$.
The query set $$$S$$$ is constructed as follows.
First, let $$$S=B(m)$$$.
If $$$v=-1$$$, do nothing; otherwise, toggle whether $$$v$$$ belongs to $$$S$$$: remove $$$v$$$ if $$$v\in S$$$, and add $$$v$$$ otherwise.
The interactor then counts the edges of the hidden path with exactly one endpoint in $$$S$$$. Let this number be: $$$$$$ c(S)= \left| \left\{ i\mid 1\le i \lt n,\ \left|\{p_i,p_{i+1}\}\cap S\right|=1 \right\} \right| $$$$$$
The interactor returns $$$c(S)\bmod 3$$$.
For each test case, you may make at most $$$nk$$$ queries, with $$$k=\lceil\log_2 n\rceil$$$ as defined above. You must reconstruct the hidden permutation $$$p$$$ within this query limit.
The interactor is non-adaptive: the hidden permutation for each test case is fixed before the interaction begins and does not change throughout the interaction.
At the beginning of the interaction, you are given an integer $$$T$$$ ($$$1\le T\le 10^4$$$), denoting the number of test cases.
For each test case, the interactor first gives you an integer $$$n$$$ ($$$1\le n\le 10^3$$$). After you output the answer for the current test case, the interaction proceeds to the next test case, if any.
It is guaranteed that the sum of $$$n$$$ over all test cases in one test file does not exceed $$$10^4$$$.
For each test case, you may perform the following two types of operations. The number of queries must not exceed $$$nk$$$, with $$$k=\lceil\log_2 n\rceil$$$ as defined above.
Query: Output a line of the form ? m v, where $$$0 \le m \lt 2^k$$$, and either $$$v=-1$$$ or $$$0 \le v \lt n$$$. Here $$$m,v$$$ must be integers. Then read an integer $$$r\in\{0,1,2\}$$$, whose value is $$$c(S) \bmod 3$$$.
Answer: Output a line of the form ! $$$q_1\ q_2\ \ldots\ q_n$$$, where $$$(q_1,q_2,\ldots,q_n)$$$ must be exactly equal to the hidden permutation $$$(p_1,p_2,\ldots,p_n)$$$.
Only operations of the form ? count toward the query limit. If the interactor returns $$$-1$$$ at any point, your program must terminate immediately. Continuing the interaction after receiving $$$-1$$$ may result in an arbitrary verdict.
After printing a query or the answer, do not forget to output the end of the line and flush the output. Otherwise, your submission may receive any verdict. To do this, use: $$$\texttt{fflush(stdout)}$$$ or $$$\texttt{cout.flush()}$$$ in C++; $$$\texttt{System.out.flush()}$$$ in Java; $$$\texttt{flush(output)}$$$ in Pascal; $$$\texttt{stdout.flush()}$$$ in Python.
2 3 1 1 0 2 1
? 1 -1 ? 1 0 ? 1 1 ? 1 2 ! 1 0 2 ! 0
For the first test case, the hidden permutation is $$$p=(1,0,2)$$$. The path has two edges: $$$\{0,1\}$$$ and $$$\{0,2\}$$$.
All four queries use $$$m=1$$$, so each query starts with $$$B(1)=\{1\}$$$:
The program then outputs ! 1 0 2. Here, $$$k=2$$$, so at most $$$nk=6$$$ queries are allowed. The example uses only four queries.
For the second test case, $$$n=1$$$, so the only possible permutation is $$$(0)$$$. The program outputs ! 0 without making any queries.