C2. Permutaion Construction(hard version)
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

This is the hard version of the problem.The only difference is that there is the third restriction.

You're given two integers $$$n$$$ and $$$x$$$.Construct a permutation $$$p$$$ of length $$$2n$$$ which satisfies:

  1. $$$p_1+p_2=p_3+p_4=...=p_{2n-1}+p_{2n}$$$
  2. $$$p_2+p_3=p_4+p_5=...=p_{2n-2}+p_{2n-1}$$$
  3. $$$p_1=x$$$

If no solution,output $$$-1$$$ instead.

Input

The first line of input will contain a single integer $$$t(1 \leq t \leq 10^5)$$$, denoting the number of test cases.

Each test case consists a single line of input.

The only line of each test case contains two integers $$$n(2 \leq n \leq 10^5),x(1 \leq x \leq 2n)$$$. The sum of $$$n$$$ over all test cases won't exceed $$$10^5$$$.

Output

For each test case, output on a new line — a permutaion of length $$$2n$$$ which satisfies the restrictions above.If no solution,output $$$-1$$$ instead.

Example
Input
3
2 3
3 5
4 6
Output
3 2 4 1
5 2 3 4 1 6
-1