Chef has an array
of length such that .
In one operation, Chef can pick any two elements of the array, delete them from , and append either their bitwise XOR or their bitwise OR to .
Note that after each operation, the length of the array decreases by .
Let be the final number obtained after operations are made. You are given an integer , determine if you can get via some sequence of operations.
In case it is possible to get , print the operations too (see the section Output format for more details), otherwise print .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of a single line containing two space-separated integers and .
Output Format
For each test case, output if it is impossible to get in the end. Otherwise print lines denoting the operations.
On each line, print
- if you want replace and with .
- if you want replace and with .
Note that and are the elements of the array at the time of applying the operation, and if either of them is not present in the array you will receive a WA verdict.
Constraints
- The sum of over all test cases won't exceed .
Sample Input 1
3
3 2
2 2
4 7
Sample Output 1
2 1 3
1 2 2
-1
1 1 2
1 3 3
1 3 4
Explanation
Test case : The operations are as follows:
- Initially, the array is
- The first move removes and and appends their , making the array
- The second move removes and and appends their , making the array
Test case : It can be shown that no sequence of operations can achieve in this case.
Test case : The operations are as follows:
- Initially, the array is
- After the first move, the array is
- After the second move, the array is
No comments:
Post a Comment