#P1773A. Amazing Trick

    ID: 435 Type: RemoteJudge 3000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>constructive algorithmsgraph matchingsmathprobabilities*1900

Amazing Trick

Description

Alice is a magician and she creates a new trick. She has nn cards with different numbers from 11 to nn written on them. First, she asks an audience member to shuffle the deck and put cards in a row. Let's say the ii-th card from the left has the number aia_i on it.

Then Alice picks two permutations pp and qq. There is a restriction on pp and qq — permutations can't have fixed points. Which means i:pii and qii\forall i: p_i \ne i\ and\ q_i \ne i.

After permutations are chosen, Alice shuffles the cards according to them. Now the ii-th card from the left is the card a[p[q[i]]a[p[q[i]]. The trick is considered successful if ii-th card from the left has the number ii on it after the shuffles.

Help Alice pick the permutations pp and qq or say it is not possible for the specific starting permutation aa.

The first line of the input contains the number of tests tt (1t1051 \leq t \leq 10^5).

Each test is described in two lines. The first line contains one integer nn — the number of cards (1n1051 \leq n \leq 10^5). The second line contains nn integers aia_i — the initial permutation of the cards (1ain1 \leq a_i \leq n; ij:aiaj\forall i \neq j: a_i \neq a_j).

It is guaranteed that the sum of nn over all tests does not exceed 10510^5.

Print the answer for each test case in the same order the cases appear in the input.

For each test case, print "Impossible" in a single line, if no solution exists.

Otherwise, print "Possible" in the first line, and in the following two lines print permutations pp and qq.

Input

The first line of the input contains the number of tests tt (1t1051 \leq t \leq 10^5).

Each test is described in two lines. The first line contains one integer nn — the number of cards (1n1051 \leq n \leq 10^5). The second line contains nn integers aia_i — the initial permutation of the cards (1ain1 \leq a_i \leq n; ij:aiaj\forall i \neq j: a_i \neq a_j).

It is guaranteed that the sum of nn over all tests does not exceed 10510^5.

Output

Print the answer for each test case in the same order the cases appear in the input.

For each test case, print "Impossible" in a single line, if no solution exists.

Otherwise, print "Possible" in the first line, and in the following two lines print permutations pp and qq.

Sample Input 1

4
2
2 1
3
1 2 3
4
2 1 4 3
5
5 1 4 2 3

Sample Output 1

Impossible
Possible
3 1 2
2 3 1
Possible
3 4 2 1
3 4 2 1
Possible
4 1 2 5 3
3 1 4 5 2