#P1543D1. RPD and Rap Sheet (Easy Version)
RPD and Rap Sheet (Easy Version)
No submission language available for this problem.
Description
This is the easy version of the problem. The only difference is that here . You can make hacks only if both the versions of the problem are solved.
This is an interactive problem.
Every decimal number has a base equivalent. The individual digits of a base number are called -its. Let's define the -itwise XOR of two -its and as .
The -itwise XOR of two base numbers is equal to the new number formed by taking the -itwise XOR of their corresponding -its. The -itwise XOR of two decimal numbers and is denoted by and is equal to the decimal representation of the -itwise XOR of the base representations of and . All further numbers used in the statement below are in decimal unless specified. When (it is always true in this version), the -itwise XOR is the same as the bitwise XOR.
You have hacked the criminal database of Rockport Police Department (RPD), also known as the Rap Sheet. But in order to access it, you require a password. You don't know it, but you are quite sure that it lies between and inclusive. So, you have decided to guess it. Luckily, you can try at most times without being blocked by the system. But the system is adaptive. Each time you make an incorrect guess, it changes the password. Specifically, if the password before the guess was , and you guess a different number , then the system changes the password to a number such that . Guess the password and break into the system.
The first line of input contains a single integer () denoting the number of test cases. test cases follow.
The first line of each test case contains two integers () and ().
It is guaranteed that the sum of over all test cases does not exceed .
Interaction
For each test case, first read two integers and . Then you may ask up to queries.
For each query, print a single integer (). Let the current password be . After that, read an integer .
If , you will read and the test case is solved. You must then continue solving the remaining test cases.
Else, you will read . At this moment the password is changed to a number such that .
After printing a query, do not forget to output the end of line and flush the output. Otherwise, you will get the Idleness limit exceeded verdict.
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.
If you ask an invalid query or exceed queries, you will read and you will receive the Wrong Answer verdict. Make sure to exit immediately to avoid unexpected verdicts.
Note that the interactor is adaptive. That is, the original password is not fixed in the beginning and may depend on your queries. But it is guaranteed that at any moment there is at least one initial password such that all the answers to the queries are consistent.
Hacks:
To use hacks, use the following format of tests:
The first line should contain a single integer () — the number of test cases.
The first and only line of each test case should contain two integers () and () denoting the number of queries and the base respectively. The optimal original password is automatically decided by the adaptive interactor.
You must ensure that the sum of over all test cases does not exceed .
Input
The first line of input contains a single integer () denoting the number of test cases. test cases follow.
The first line of each test case contains two integers () and ().
It is guaranteed that the sum of over all test cases does not exceed .
Samples
Note
In the example test case, the hidden password is .
The first query is . It is not equal to the current password. So, is returned, and the password is changed to since .
The second query is . It is not equal to the current password. So, is returned, and the password is changed to since .
The third query is . It is equal to the current password. So, is returned, and the job is done.
Note that this initial password is taken just for the sake of explanation. When you submit, the interactor might behave differently because it is adaptive.