CF1917A.Least Product

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

Least Product

You are given an array of integers a1,a2,,ana_1, a_2, \dots, a_n. You can perform the following operation any number of times (possibly zero):

  • Choose any element aia_i from the array and change its value to any integer between 00 and aia_i (inclusive). More formally, if ai<0a_i \lt 0, replace aia_i with any integer in [ai,0][a_i, 0], otherwise replace aia_i with any integer in [0,ai][0, a_i].

Let rr be the minimum possible product of all the aia_i after performing the operation any number of times.

Find the minimum number of operations required to make the product equal to rr. Also, print one such shortest sequence of operations. If there are multiple answers, you can print any of them.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t5001 \leq t \leq 500) - the number of test cases. This is followed by their description.

The first line of each test case contains the a single integer nn (1n1001 \leq n \leq 100) — the length of the array.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (109ai109-10^9 \leq a_i \leq 10^9).

Output

For each test case:

  • The first line must contain the minimum number of operations kk (0kn0 \leq k \leq n).
  • The jj-th of the next kk lines must contain two integers ii and xx, which represent the jj-th operation. That operation consists in replacing aia_i with xx.

Note

In the first test case, we can change the value of the first integer into 00 and the product will become 00, which is the minimum possible.

In the second test case, initially, the product of integers is equal to 28(1)3=482 \cdot 8 \cdot (-1) \cdot 3 = -48 which is the minimum possible, so we should do nothing in this case.

Samples

4
1
155
4
2 8 -1 3
4
-1 0 -2 -5
4
-15 -75 -25 -30
1
1 0
0
0
1
3 0

在线编程 IDE

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