Problem: This is an interactive problem.
Note: the XOR-sum of an array () is defined as , where denotes the bitwise XOR operation.
Little Dormi received an array of integers for Christmas. However, while playing with it over the winter break, he accidentally dropped it into his XOR machine, and the array got lost.
The XOR machine is currently configured with a query size of (which you cannot change), and allows you to perform the following type of query: by giving the machine distinct indices , it will output .
As Little Dormi's older brother, you would like to help him recover the XOR-sum of his array by querying the XOR machine.
Little Dormi isn't very patient, so to be as fast as possible, you must query the XOR machine the minimum number of times to find the XOR-sum of his array. Formally, let be the minimum number of queries needed to find the XOR-sum of any array of length with a query size of . Your program will be accepted if you find the correct XOR-sum in at most queries.
Lastly, you also noticed that with certain configurations of the machine and values of , it may not be possible to recover the XOR-sum of Little Dormi's lost array. If that is the case, you should report it as well.
The array is fixed before you start querying the XOR machine and does not change with the queries.
Input Format: The only line of input contains the integers and (, ), the length of the lost array and the configured query size of the XOR machine.
Elements of the original array satisfy .
It can be proven that that if it is possible to recover the XOR sum under the given constraints, it can be done in at most queries. That is, .
After taking and , begin interaction.
Output Format: If it is impossible to recover the XOR-sum of the array, output immediately after taking and . Do not begin interaction.
Otherwise, when your program finds the XOR-sum of the lost array , report the answer in the following format: "! x", where is the XOR sum of the array , and terminate your program normally immediately after flushing the output stream.
Note that answering does not count as a query.
Note: In the first example interaction, the array is and its XOR-sum is .
The first query made asks for indices , so the response is .
The second query made asks for indices , so the response is .
The third query made asks for indices , so the response is . Note that the indices may be output in any order.
Additionally, even though three queries were made in the example interaction, it is just meant to demonstrate the interaction format and does not necessarily represent an optimal strategy.
In the second example interaction, there is no way to recover the XOR-sum of Little Dormi's array no matter what is queried, so the program immediately outputs and exits.