Subsegment Divisibility

 JJ challenges his friend GG to construct an array 

A containing N distinct elements such that the following conditions hold:

  • For all 1iN1Ai105
  • For every subarray of length 2, the sum of all the elements of the subarray is not divisible by the length of the subarray

Please help perplexed GG to complete JJ's challenge.

Input Format

  • The first line contains T - the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains an integer N - the size of the array A to be constructed.

Output Format

For each test case, output an array A containing N distinct elements which satisfy the given conditions.

If there are multiple arrays that satisfy the conditions, print any.

Constraints

  • 1T10
  • 1N500

Sample Input 1 

2
3
4

Sample Output 1 

7 2 5
3 18 11 2

Explanation

Test case-1: Following are the subarrays of length 2:

  • Length=2sum([7,2])=9sum([2,5])=7
  • Length=3sum([7,2,5])=14

We can see that for each of these subarrays, the sum is not divisible by the length.

Test case-2: Following are the subarrays of length 2:

  • Length=2sum([3,18])=21sum([18,11])=29sum([11,2])=13
  • Length=3sum([3,18,11])=32sum([18,11,2])=31
  • Length=4sum([3,18,11,2])=34

We can see that for each of these subarrays, the sum is not divisible by the length.

Previous
Next Post »