Hide

Problem J
Prime Differences

Given an integer $n$, print a permutation of size $n$ such that for all $1 \le i < n$, the value $|a_ i - a_{i+1}|$ is prime, or state that there is no solution.

\includegraphics[scale=0.5]{primepermutation.png}

A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array), and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the array).

Recall that a prime number is any positive integer greater than $1$ whose only factors are $1$ and itself. So, for example, $2$ and $13$ are prime, and $1$ and $6$ are not.

Input

The first line of the input contains a single integer $t$ ($1 \le t \le 500$) —the number of test cases. The description of the test cases follows.

Each test case consists of a single line with an integer $n$ ($1 \le n \le 2\cdot 10^5$) —the size of the desired permutation.

It is guaranteed that the sum of $n$ over all test cases is at most $2\cdot 10^5$.

Output

For each test case, if there is no solution, print a single integer $-1$. Otherwise, print a line containing n integers —a valid permutation of size $n$.

If there are multiple solutions, print any.

Sample Input 1 Sample Output 1
5
1
2
7
9
10
1
-1
1 4 6 3 5 7 2
6 9 4 2 7 5 3 8 1
3 10 7 9 4 6 1 8 5 2

Please log in to submit a solution to this problem

Log in