#P1869A. Make It Zero
Make It Zero
No submission language available for this problem.
Description
During Zhongkao examination, Reycloer met an interesting problem, but he cannot come up with a solution immediately. Time is running out! Please help him.
Initially, you are given an array consisting of integers, and you want to change all elements in it to .
In one operation, you select two indices and () and do the following:
- Let , where denotes the bitwise XOR operation;
- Then, for all , replace with .
You can use the operation above in any order at most times in total.
Find a sequence of operations, such that after performing the operations in order, all elements in are equal to . It can be proven that the solution always exists.
The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the length of the array .
The second line of each test case contains integers () — the elements of the array .
For each test case, in the first line output a single integer () — the number of operations you use.
Then print lines, in the -th line output two integers and () representing that you select and in the -th operation.
Note that you do not have to minimize . If there are multiple solutions, you may output any of them.
Input
The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the length of the array .
The second line of each test case contains integers () — the elements of the array .
Output
For each test case, in the first line output a single integer () — the number of operations you use.
Then print lines, in the -th line output two integers and () representing that you select and in the -th operation.
Note that you do not have to minimize . If there are multiple solutions, you may output any of them.
Note
In the first test case, since , after performing the operation on segment , all the elements in the array are equal to .
In the second test case, after the first operation, the array becomes equal to , after the second operation, the array becomes equal to .
In the third test case:
Operation | before | after | |
In the fourth test case, the initial array contains only , so we do not need to perform any operations with it.