CF1762B.Make Array Good

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Make Array Good

An array bb of mm positive integers is good if for all pairs ii and jj (1i,jm1 \leq i,j \leq m), max(bi,bj)\max(b_i,b_j) is divisible by min(bi,bj)\min(b_i,b_j).

You are given an array aa of nn positive integers. You can perform the following operation:

  • Select an index ii (1in1 \leq i \leq n) and an integer xx (0xai0 \leq x \leq a_i) and add xx to aia_i, in other words, ai:=ai+xa_i := a_i+x.
  • After this operation, ai1018a_i \leq 10^{18} should be satisfied.

You have to construct a sequence of at most nn operations that will make aa good. It can be proven that under the constraints of the problem, such a sequence of operations always exists.

Input

Each test contains multiple test cases. The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1051 \leq n \leq 10^5) — the length of the array aa.

The second line of each test case contains nn space-separated integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1091 \leq a_i \leq 10^9) — representing the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output

For each test, output a single integer pp (0pn0 \leq p \leq n) — denoting the number of operations in your solution.

In each of the following pp lines, output two space-separated integers — ii and xx.

You do not need to minimize the number of operations. It can be proven that a solution always exists.

Note

In the first test case, array aa becomes [5,5,5,5][5,5,5,5] after the operations. It is easy to see that [5,5,5,5][5,5,5,5] is good.

In the second test case, array aa is already good.

In the third test case, after performing the operations, array aa becomes [10,5,350,5,10][10,5,350,5,10], which is good.

In the fourth test case, after performing the operations, array aa becomes [60,10,20][60,10,20], which is good.

Samples

4
4
2 3 5 5
2
4 8
5
3 4 343 5 6
3
31 5 17
4
1 2
1 1
2 2
3 0
0
5
1 3
1 4
2 1
5 4
3 7
3
1 29
2 5
3 3

在线编程 IDE

建议全屏模式获得最佳体验