CF2137B.Fun Permutation

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

Fun Permutation

You are given a permutation^{\text{∗}} pp of size nn.

Your task is to find a permutation qq of size nn such that GCD\operatorname{GCD}^{\text{†}}(pi+qi,pi+1+qi+1)3(p_i+q_i, p_{i+1}+q_{i+1}) \geq 3 for all 1i<n1 \leq i \lt n. In other words, the greatest common divisor of the sum of any two adjacent positions should be at least 33.

It can be shown that this is always possible.

^{\text{∗}}A permutation of length mm is an array consisting of mm distinct integers from 11 to mm in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (m=3m=3 but there is 44 in the array).

^{\text{†}}gcd(x,y)\gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

Input

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

The first line of each test case contains an integer nn (2n21052 \leq n \leq 2\cdot 10^5).

The second line contains nn integers p1,p2,,pnp_1,p_2,\ldots,p_n (1pin1 \leq p_i \leq n).

It is guaranteed that the given array forms a permutation.

It is guaranteed that the sum of nn over all test cases does not exceed 21052\cdot 10^5.

Output

For each test case, output the permutation qq on a new line. If there are multiple possible answers, you may output any.

Note

In the first test case, GCD(1+2,3+3)=33\operatorname{GCD}(1+2,3+3)=3\geq 3 and GCD(3+3,2+1)=33\operatorname{GCD}(3+3,2+1)=3\geq3, so the output is correct.

Samples

3
3
1 3 2
5
5 1 2 4 3
7
6 7 1 5 4 3 2
2 3 1
4 5 1 2 3
2 1 3 7 5 6 4

在线编程 IDE

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