## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Xor Permutation CodeChef Solution

Given $N$, find a permutation $P$ of numbers $\left(1,2,\dots ,N\right)$ such that:

• . Here $\oplus$ denotes the bitwise XOR operation.

If multiple such permutations exist, print any. If no such permutation exists, print $-1$.

Note that, a permutation of length $N$ is a sequence of $N$ integers $P=\left({P}_{1},{P}_{2},\dots ,{P}_{N}\right)$ such that every integer from $1$ to $N$ (inclusive) appears in it exactly once. For example, $\left(2,5,4,1,3\right)$ is a permutation of length $5$ while $\left(2,5,2,1,3\right)$ is not.

Solution Click Below:-  👉
👇👇👇👇👇

### Input Format

• First line will contain $T$, number of test cases. Then the test cases follow.
• Each test case contains of a single integer as input, $N$ - the length of the required permutation.

### Output Format

For each test case, output in a new line, $N$ space-separated integers, denoting a permutation satisfying the condition.
If multiple such permutations exist, print any. If no such permutation exists, print $-1$.

### Constraints

• $1\le T\le 500$
• $3\le N\le {10}^{5}$
• Sum of $N$ over all test cases does not exceed