Find Permutation

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 4657
64-bit integer IO format: %I64d      Java class name: Main
Special Judge

Description

Given b0, b1, ..., bn-1, find two permutations {ai}, {ci} of 0..n-1 such that ai+bi=ci (mod n) for every i.

Input

First line, number of test cases, T.
Following are 2*T. For every two lines, the first line is n and the second line contains n integers.

Sum of all n <= 105.
0<=bi<n
It's guaranteed that there exists a solution.
Test data is generated by randomly choosing two permutations and subtracting one from the other.

Output

2*T lines. Every line contains n integers. For every two lines, the first line represents {ai} and the second line represents {ci}.
If there are multiple solutions, output any one of them.

Sample Input

1
3
0 1 2

Sample Output

2 0 1
2 1 0

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .