#P1416B. Make Them Equal
Make Them Equal
No submission language available for this problem.
Description
You are given an array consisting of positive integers, numbered from to . You can perform the following operation no more than times:
- choose three integers , and (; );
- assign , .
After each operation, all elements of the array should be non-negative.
Can you find a sequence of no more than operations after which all elements of the array are equal?
The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case contains one integer () — the number of elements in the array. The second line contains integers () — the elements of the array.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case print the answer to it as follows:
- if there is no suitable sequence of operations, print ;
- otherwise, print one integer () — the number of operations in the sequence. Then print lines, the -th of which should contain three integers , and (; ) for the -th operation.
If there are multiple suitable sequences of operations, print any of them. Note that you don't have to minimize .
Input
The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case contains one integer () — the number of elements in the array. The second line contains integers () — the elements of the array.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case print the answer to it as follows:
- if there is no suitable sequence of operations, print ;
- otherwise, print one integer () — the number of operations in the sequence. Then print lines, the -th of which should contain three integers , and (; ) for the -th operation.
If there are multiple suitable sequences of operations, print any of them. Note that you don't have to minimize .