CF1739B.Array Recovery

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

Array Recovery

For an array of non-negative integers aa of size nn, we construct another array dd as follows: d1=a1d_1 = a_1, di=aiai1d_i = |a_i - a_{i - 1}| for 2in2 \le i \le n.

Your task is to restore the array aa from a given array dd, or to report that there are multiple possible arrays.

Input

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains one integer nn (1n1001 \le n \le 100) — the size of the arrays aa and dd.

The second line contains nn integers d1,d2,,dnd_1, d_2, \dots, d_n (0di1000 \le d_i \le 100) — the elements of the array dd.

It can be shown that there always exists at least one suitable array aa under these constraints.

Output

For each test case, print the elements of the array aa, if there is only one possible array aa. Otherwise, print 1-1.

Note

In the second example, there are two suitable arrays: [2,8,5][2, 8, 5] and [2,8,11][2, 8, 11].

Samples

3
4
1 0 2 5
3
2 6 3
5
0 0 0 0 0
1 1 3 8
-1
0 0 0 0 0

在线编程 IDE

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