#C9130. Alternating Even-Odd Sequence Generator
Alternating Even-Odd Sequence Generator
Alternating Even-Odd Sequence Generator
You are given a positive integer n. Your task is to generate a sequence of n distinct integers by selecting numbers from the set \(\{1,2,\dots,2n\}\) such that the sequence alternates between even and odd numbers, starting with an even number.
More formally, let the sequence be \(a_1, a_2, \dots, a_n\), then:
- \(a_1\) is even,
- \(a_2\) is odd,
- \(a_3\) is even,
- and so on.
Each number must be unique and chosen from \(\{1,2,\dots,2n\}\). For instance, when \(n = 3\), one valid sequence is 2 1 4
.
inputFormat
The input is given via standard input (stdin) and is formatted as follows:
T n1 n2 ... nT
Here, the first line contains a single integer T denoting the number of test cases. Each of the following T lines contains a single integer n representing the length of the sequence to be generated.
outputFormat
For each test case, output a single line containing the generated sequence. The numbers in the sequence should be separated by a single space. The output should be written to the standard output (stdout).
For example, if the test case is 3
, then a valid output would be: 2 1 4
1
3
2 1 4