#P7703. 「MCOI-09」Dream and Strings REMATCH

「MCOI-09」Dream and Strings REMATCH

Description

Given NN and a non-negative integer sequence a1,a2,,aNa_1,a_2,\dots,a_N.

Please find any integer sequence b1,b2,,bNb_1,b_2,\dots,b_N such that bi0\sum |b_i|\neq 0, bi1|b_i|\le 1, and aibi=0\sum a_i b_i = 0.

Input Format

The first line contains a positive integer TT. Then follow TT test cases.

Each test case consists of two lines. The first line contains a positive integer NN, and the next line contains NN non-negative integers a1,a2,,aNa_1,a_2,\dots,a_N.

Output Format

Output TT lines. The TT-th line should output the sequence bb for the corresponding test case.

If there is no solution, output 1-1.

2
5
1 1 2 60 60
4
100 101 100 102
1 1 -1 1 -1
1 0 -1 0

Hint

This sample does not satisfy the constraint 5000N5000\le N.

This problem uses bundled tests.

  • Subtask 1 (50 pts): 105N10^5\le N.
  • Subtask 2 (50 pts): no special constraints.

Constraints for 100%100\% of the testdata: 1T201\le T\le 20, 5000N105T5000\le N\le\frac{10^5}{T}, 0ai10180\le a_i\le 10^{18}. The testdata is guaranteed to be randomly generated.

Translated by ChatGPT 5