C. Sums on Segments
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array $$$a$$$ of $$$n$$$ integers, where all elements except for at most one are equal to $$$-1$$$ or $$$1$$$. The remaining element $$$x$$$ satisfies $$$-10^9 \le x \le 10^9$$$.

Find all possible sums of subarrays of $$$a$$$, including the empty subarray, whose sum is defined as $$$0$$$. In other words, find all integers $$$x$$$ such that the array $$$a$$$ has at least one subarray (possibly empty) with sum equal to $$$x$$$. A subarray is a contiguous subsegment of an array.

Output these sums in ascending order. Each sum should be printed only once, even if it is achieved by multiple subarrays.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then, $$$t$$$ test cases follow.

Each test case consists of two lines:

  • The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the array.
  • The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$) — the elements of the array $$$a$$$. In the array $$$a$$$, there is at most one element that is neither $$$1$$$ nor $$$-1$$$.

Additional constraint on the input: the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

Output

For each test case, output two lines:

  • In the first line, print a single integer — the number of distinct subarray sums.
  • In the second line, print these sums in ascending order.

Each sum should be printed only once, even if it is produced by multiple subarrays.

Example
Input
5
5
1 -1 10 1 1
5
-1 -1 -1 -1 -1
2
-1 2
2
7 1
3
1 4 -1
Output
8
-1 0 1 2 9 10 11 12 
6
-5 -4 -3 -2 -1 0 
4
-1 0 1 2 
4
0 1 7 8 
6
-1 0 1 3 4 5 
Note

Let's define $$$a[i,j]$$$ as the subarray of $$$a$$$ from position $$$i$$$ to position $$$j$$$.

Consider the first test case of the example:

  • $$$-1$$$ is produced by $$$a[2,2]$$$;
  • $$$0$$$ is produced by the empty subarray;
  • $$$1$$$ is produced by $$$a[4,4]$$$;
  • $$$2$$$ is produced by $$$a[4,5]$$$;
  • $$$9$$$ is produced by $$$a[2,3]$$$;
  • $$$10$$$ is produced by $$$a[1,3]$$$;
  • $$$11$$$ is produced by $$$a[3,4]$$$;
  • $$$12$$$ is produced by $$$a[3,5]$$$.