D. Tournament
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A tournament is a directed graph in which for every unordered pair of vertices $$$(i, j)$$$ where $$$i \neq j$$$, there is either an edge from $$$i$$$ to $$$j$$$ or an edge from $$$j$$$ to $$$i$$$, but not both.

Call a vertex $$$u$$$ in a tournament good, if for every other vertex $$$v$$$, there exists a path from $$$u$$$ to $$$v$$$ with at max $$$3$$$ edges. Your task is to find a good vertex. There is a hidden tournament with $$$n$$$ vertices numbered $$$0, 1, \ldots n - 1$$$, and the only way you can extract information about it is by asking queries of the form (without quotes):

"? i j"

For each such query, the judge replies 1 if there is an edge from $$$i$$$ to $$$j$$$ in the tournament and 0 otherwise. After making some queries (limit on the number of queries specified later), you should output(without quotes):

"! v"

where $$$v$$$ is any good vertex. It can be proved that a good vertex always exists. If there exist multiple good vertices, you can output any of them.

Note that the grader is adaptive, which means that the graph is not fixed before the interaction begins. However, the judge will never contradict the replies given in the past. For example, if the judge has replied 1 for a query "? i j" in the past, then for every future query "? i j", the judge will reply 1, and for every future query "? j i", the judge will reply 0

Interaction

First read an integer $$$T(1 \leq T \leq 2000)$$$, which means the number of test cases. Each test case should be considered independently. For each test case,

  • First read an integer $$$n (1 \leq n \leq 2000)$$$
  • Then, whenever you want to know if there is an edge from $$$i$$$ to $$$j$$$, you should output "? i j", without quotes. The judge replies 1 if there is an edge from $$$i$$$ to $$$j$$$ in the tournament and 0 otherwise.
  • When you have found a good vertex, say $$$v$$$, you should output "! v", without quotes, and then immediately move to the next test case if any.

The sum of $$$n$$$ over all test cases doesn't exceed $$$2000$$$. Your solution is accepted if you output a good vertex for every test case, and the sum of the number of queries asked over all the testcases doesn't exceed $$${\bf 15000}$$$.

Example
Input
2
3

1

0

0

1

2

0
Output


? 0 1

? 2 1

? 1 0

? 0 2

! 0

? 0 1

! 1
Note
  • Only the queries of the form "? i j" are counted towards the number of queries, when comparing with the limit on number of queries.
  • After printing a query do not forget to output the end of line and flush the output.