JJ is back with another challenge. He challenges you to construct an array containing integers such that the following conditions hold:
- For all ,
- Every subarray has non-zero XOR. That is, for every , . Here, denotes the bitwise XOR operation.
Can you complete JJ's challenge?
Under the given constraints, it can be proved that there always exists at least one array satisfying these conditions. If there are multiple possible arrays, print any of them.
Input Format
- The first line contains a single integer , denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains an integer — the size of the array to be constructed.
Output Format
For each test case, output a single line containing space-separated integers, denoting the elements of array . The of these integers is . If multiple arrays exist which satisfy the conditions, print any of them.
Constraints
- It is guaranteed that the sum of over all test cases does not exceed .
Sample Input 1
3
1
6
6
Sample Output 1
7
1 2 4 8 16 32
2 3 5 7 11 13
Explanation
Test Case : There is only one subarray, . Its XOR is non-zero.
Test Case : Some of the subarray XORS are:
- .
Similarly, it can be checked that every subarray has non-zero XOR.
Test Case : Some of the subarray XORS are:
Similarly, it can be checked that every subarray has non-zero XOR.
Solution:
No comments:
Post a Comment