#C4427. Rearrange the Queue

    ID: 47964 Type: Default 1000ms 256MiB

Rearrange the Queue

Rearrange the Queue

You are given several groups of people standing in a queue. For each group, you are given the heights of the people. Your task is to rearrange the queue for each test case such that the heights are in strictly increasing order. If all people have the same height, it is not possible to rearrange and you should output IMPOSSIBLE.

Constraints:

  • For each test case, if all the numbers are identical, output IMPOSSIBLE.
  • Otherwise, output the heights in ascending order separated by a single space.

Note: You must read the input from stdin and output the result to stdout.

The formula for the condition (if not all equal) can be expressed as:

\( \exists i, j \text{ such that } a_i \neq a_j \)

inputFormat

The first line of input contains a single integer T denoting the number of test cases. The description of T test cases follows.

For each test case:

  • The first line contains an integer N, the number of people in the queue.
  • The second line contains N space-separated integers representing the heights of the people.

Input is read from stdin.

outputFormat

For each test case, output a single line containing the rearranged queue as space-separated integers, or the string IMPOSSIBLE if a valid rearrangement does not exist.

Output should be written to stdout.

## sample
5
4
4 2 7 6
3
1 3 2
5
5 3 1 4 2
4
1 1 1 1
2
100 99
2 4 6 7

1 2 3 1 2 3 4 5 IMPOSSIBLE 99 100

</p>