This problem is similar to the problem "INTREECTIVE2". The only difference between them is the number of queries allowed — in this problem, up to 21 queries can be made. In Div. 1 and Div. 2 this problem is worth 40 points and "INTREECTIVE2" is worth 60. In Div. 3 this problem is non-scorable.
This is an interactive task
You are given a tree consisting of nodes, numbered from to . Chef selected an arbitrary node and marked it.
Chef gave you a judge to play with, using which you can ask queries about the given tree.
In each query, you give the judge a non-empty set of nodes. The judge returns if there exists and (not necessarily distinct) such that and the marked node lies on the shortest path from to , or otherwise.
You have to find the marked node.
For each test case, you can use at most 21 queries.
Interaction
Begin the interaction by reading a single integer denoting the number of test cases. The description of interaction for test cases follows.
For each test case, first read a single integer , denoting the number of nodes in the tree.
lines follow. The of these lines contains two space-separated integers and , denoting an edge between the nodes and .
It is guaranteed that the given graph is a tree.
Now you may begin asking queries. To ask a query about a set of nodes ( all are distinct), output:
?
You will then receive an integer . is if there exists and (not necessarily distinct) such that and the marked node lies on the path from to , or otherwise.
When you have found the marked node(say ), print the answer in the following format:
!
Outputting the answer doesn't count towards the limit of queries.
If at any time you make an invalid query or exceed the query limit, the interaction is terminated and you will receive a Wrong Answer verdict.
If you receive a Judge Error verdict, that means your program actually has one of many possible errors: an Idleness Limit Exceeded error (it is waiting for input that does not exist), a Runtime error, you asked an invalid query, or possibly some other error.
Don't forget to flush the output after printing each line!
Constraints
- The input graph is a tree
- Sum of does not exceed over all test cases
- At most queries can be made.
Sample Interaction
Grader You
2
2
1 2
? 1 1
0
! 2
4
1 2
1 4
1 3
? 3 1 2 3
1
? 1 3
1
! 3
Explanation
Test case : After the query, we know that node hasn't been marked. So, we are left with only one possibility — node .
Test case : Chef marked the node 3.
ConversionConversion EmoticonEmoticon