12059 - EECS_2018_Mid1-3   

Description

Given a sequence of n distinct integers, sort and print the integers in increasing order with their original positions in the input sequence.
For example, if the original sequence is 7 -3 2 5 12 8
The output should be
-3,2,5,7,8,12
2,3,4,1,6,5

The first line lists the sorted integers in increasing order.
The second lists the original positions of the corresponding integers:
-3 is the second number is the original sequence, 2 is the third number,
5 is the fourth number, and 7 is the first number, so on and so forth.

Input

The first line is an integer T (T <= 20) denoting the number of test cases.

Each test case consists of two lines. The first line contains a number n (n <= 104) indicating the length of the sequence, and the second line contains the sequence of n distinct integers V1, V2, ..., Vn. (-2^31< Vi < 2^31-1 for 1 <= i <= n )

Output

The output of each test case contains two lines. 
The first line lists the sorted integers from the smallest one to the largest one ended by '\n'. Two adjacent numbers should be separated by a comma ',' and no whitespaces in between. The second line lists the original positions, also separated by ',' without whitespace and ended with '\n'.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss