#P1780D. Bit Guessing Game
Bit Guessing Game
Description
This is an interactive problem.
Kira has a hidden positive integer , and Hayato needs to guess it.
Initially, Kira gives Hayato the value — the number of unit bits in the binary notation of . To guess , Hayato can only do operations of one kind: choose an integer and subtract it from . Note that after each operation, the number changes. Kira doesn't like bad requests, so if Hayato tries to subtract a number greater than , he will lose to Kira. After each operation, Kira gives Hayato the updated value — the number of unit bits in the binary notation of the updated value of .
Kira doesn't have much patience, so Hayato must guess the original value of after no more than operations.
Since Hayato is in elementary school, he asks for your help. Write a program that guesses the number . Kira is an honest person, so he chooses the initial number before all operations and does not change it afterward.
The input data contains several test cases. The first line contains one integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains the number — the initial number of unit bits in the binary notation .
The hidden integer satisfies the following constraint: .
Interaction
To guess , you can perform the operation at most times. To do that, print a line with the following format: "- x" ().
After this operation, the number is subtracted from , and therefore is changed. If the number is greater than the current value of , then the request is considered invalid.
After the operation read a line containing a single non-negative integer — the number of unit bits in the binary notation of the current after the operation.
When you know the initial value of , print one line in the following format: "! n" ().
After that, move on to the next test case, or terminate the program if there are none.
If your program performs more than operations for one test case, subtracts a number greater than , or makes an incorrect request, then response to the request will be -1, after receiving such response, your program must exit immediately to receive the Wrong Answer verdict. Otherwise, you can get any other verdict.
After printing a query or the answer, do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
Hacks
To make a hack, use the following format.
The first line should contain a single integer ().
Each test case should contain one integer () on a separate line.
Input
The input data contains several test cases. The first line contains one integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains the number — the initial number of unit bits in the binary notation .
The hidden integer satisfies the following constraint: .
Note
For example, the number of unit bits in number is , because binary notation of is . For the number of unit bits is , because .
In the first test case, , so the input is the number . After subtracting one from , it becomes zero, so the number of unit bits in it is .
In the third test case, , which in binary representation looks like , so the input is the number of ones, that is . After subtracting , , so the number of unit bits is now . After subtracting one from , it becomes equal to zero.
Note that the blank lines in the input and output examples are shown for clarity and are not present in the actual interaction.