#P14025. [ICPC 2024 Nanjing R] P ⊕ Q = R
[ICPC 2024 Nanjing R] P ⊕ Q = R
Description
Alice wants to train herself to solve constructive problems. So her friend Kei, a super artificial intelligence, generates the following problem for Alice.
Given an integer , construct two permutations and of , such that the sequence is still a permutation of , where . Here means the bitwise exclusive-or of and .
Alice solves this problem with her powerful calculating ability and she decides to share this problem with you. Can you solve it?
Input Format
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases. For each test case:
The first and only line contains one integer () indicating the length of the permutation.
It is guaranteed that the sum of of all test cases will not exceed .
Output Format
For each test case:
If there exist two permutations satisfying the constraint, first output in one line. Then output a second line containing integers separated by a space. Finally output a third line containing integers separated by a space. If there are multiple valid answers, you can output any of them.
If there do not exist two permutations satisfying the constraint, just output in one line.
2
3
4
No
Yes
0 2 1 3
3 2 0 1
Hint
For the second test case, is still a permutation of .
:::align{center}
:::
京公网安备 11011102002149号