#K73662. Constructing a Balanced Array

    ID: 34026 Type: Default 1000ms 256MiB

Constructing a Balanced Array

Constructing a Balanced Array

You are given a positive integer \( N \). Your task is to construct a balanced array of length \( N \) containing distinct integers selected from the set \( \{1, 2, \ldots, 2N\} \).

The array is defined balanced as follows:

  • If \( N \) is even, let \( \text{half} = N/2 \). Then, the first \( \text{half} \) elements are the first \( \text{half} \) odd numbers and the remaining \( \text{half} \) elements are the first \( \text{half} \) even numbers.
  • If \( N \) is odd, let \( \text{half} = \lfloor N/2 \rfloor \). Then, the first \( \text{half}+1 \) elements are the first \( \text{half}+1 \) odd numbers, and the remaining \( \text{half} \) elements are the first \( \text{half} \) even numbers.

For example, when \( N = 4 \) (even), the array is: [1, 3, 2, 4]. When \( N = 5 \) (odd), the array is: [1, 3, 5, 2, 4].

Your solution should read input from stdin and produce output to stdout as specified in the Input and Output sections.

inputFormat

The first line of input contains an integer \( T \) (the number of test cases). The following \( T \) lines each contain a single integer \( N \) representing the length of the balanced array to be constructed.

Input is provided via stdin.

outputFormat

For each test case, output a single line containing \( N \) space-separated integers which form the balanced array according to the problem conditions. Output should be written to stdout.

## sample
3
4
5
6
1 3 2 4

1 3 5 2 4 1 3 5 2 4 6

</p>