#P1689B. Mystic Permutation
Mystic Permutation
No submission language available for this problem.
Description
Monocarp is a little boy who lives in Byteland and he loves programming.
Recently, he found a permutation of length . He has to come up with a mystic permutation. It has to be a new permutation such that it differs from the old one in each position.
More formally, if the old permutation is and the new one is it must hold that
Monocarp is afraid of lexicographically large permutations. Can you please help him to find the lexicographically minimal mystic permutation?
There are several test cases in the input data. The first line contains a single integer () — the number of test cases. This is followed by the test cases description.
The first line of each test case contains a positive integer () — the length of the permutation.
The second line of each test case contains distinct positive integers (). It's guaranteed that is a permutation, i. e. for all .
It is guaranteed that the sum of does not exceed over all test cases.
For each test case, output positive integers — the lexicographically minimal mystic permutations. If such a permutation does not exist, output instead.
Input
There are several test cases in the input data. The first line contains a single integer () — the number of test cases. This is followed by the test cases description.
The first line of each test case contains a positive integer () — the length of the permutation.
The second line of each test case contains distinct positive integers (). It's guaranteed that is a permutation, i. e. for all .
It is guaranteed that the sum of does not exceed over all test cases.
Output
For each test case, output positive integers — the lexicographically minimal mystic permutations. If such a permutation does not exist, output instead.
Samples
Note
In the first test case possible permutations that are mystic are and . Lexicographically smaller of the two is .
In the second test case, is the lexicographically minimal permutation and it is also mystic.
In third test case possible mystic permutations are , , , , , , , and . The smallest one is .