题目描述
Given a positive integer N, find a possible arrangement of the integers from 0 to N -1 such that the binary representation of every number (except the first) differs at most at one bit from the binary representation of the number before it. Or tell that it’s impossible to get such an arrangement.
------ Input ------
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains a single integer N.
------ Output ------
For every testcase print N integers on a single line, the required sequence. If there are multiple possible answers, print any one.
If no such sequence is possible, print -1.
------ Constraints ------
$1 ≤ T ≤ 2000$
$1 ≤ N ≤ 100000$
$1 ≤ sum of N over all test cases ≤ 2000000$
------ Example ------
Input:
5
1
2
3
4
5
Output:
0
0 1
2 0 1
0 1 3 2
4 0 1 3 2
------ Explanation ------
Binary representation of the numbers in the output for N=5 are :
100, 000, 001, 011, and 010.
输入格式
见题面
输出格式
见题面