#P1799B. Equalize by Divide
Equalize by Divide
Description
You are given an array of positive integers.
You can make this operation multiple (possibly zero) times:
- Choose two indices , (, ).
- Assign . Here denotes rounded up to the smallest integer .
Is it possible to make all array elements equal by some sequence of operations (possibly empty)? If yes, print any way to do it in at most operations.
It can be proven, that under the problem constraints, if some way exists to make all elements equal, there exists a way with at most operations.
The first line contains a single integer () — the number of test cases. Descriptions of test cases follow.
The first line of each test case description contains a single integer ().
The second line of each test case description contains integers ().
It is guaranteed, that the sum of for all test cases does not exceed .
For each test case print a single integer (). If , there is no solution, otherwise is equal to the number of operations.
If , on the next lines print two integers , (, ) — descriptions of operations.
If there are multiple solutions, you can print any.
Input
The first line contains a single integer () — the number of test cases. Descriptions of test cases follow.
The first line of each test case description contains a single integer ().
The second line of each test case description contains integers ().
It is guaranteed, that the sum of for all test cases does not exceed .
Output
For each test case print a single integer (). If , there is no solution, otherwise is equal to the number of operations.
If , on the next lines print two integers , (, ) — descriptions of operations.
If there are multiple solutions, you can print any.
Note
In the first and second, fourth test cases all numbers are equal, so it is possible to do nothing.
In the third test case, it is impossible to make all numbers equal.
In the fifth test case: .
In the sixth test case: .
Here the red numbers are indices (that will be assigned), blue numbers are indices.