logo AlgoBeat OnlineJudge
登录 注册

#212851. [NERC 2022] Amazing Trick

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

Then Alice picks two permutations and . There is a restriction on and --- . Which means .

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

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

输入格式

The first line of the input contains the number of tests ().

Each test is described in two lines. The first line contains one integer --- the number of cards (). The second line contains integers --- the initial permutation of the cards (; ).

It is guaranteed that the sum of over all tests does not exceed .

输出格式

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

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

Otherwise, print in the first line, and in the following two lines print permutations and .

样例

样例输入 1

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

样例输出 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