#K67992. Beautiful Sequence
Beautiful Sequence
Beautiful Sequence
You are given an integer N representing the length of a sequence. Your task is to determine whether a Beautiful Sequence exists for the given N and, if it does, output the sequence. A sequence is considered Beautiful if it meets the following criteria:
- If \(N = 1\), the sequence is \([1]\).
- If \(N = 2\), the sequence is \([1, 2]\).
- If \(N = 3\), a Beautiful Sequence does not exist.
- If \(N \ge 4\), a Beautiful Sequence is constructed by alternating 1 and 2, i.e. for \(i = 1,2,\ldots,N\), the \(i^{th}\) element is given by:</p>
\(a_i = \begin{cases} 1 & \text{if } i \text{ is odd}\\ 2 & \text{if } i \text{ is even} \end{cases}\)
For each test case, if a Beautiful Sequence exists, output YES
followed by the sequence elements separated by spaces; otherwise, output NO
.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a single integer N, the length of the sequence.
Input is read from stdin.
outputFormat
For each test case, output one line. If a Beautiful Sequence exists for the given N, output YES
followed by the sequence elements (separated by a single space). If not, output NO
.
Output is written to stdout.
## sample3
1
2
3
YES 1
YES 1 2
NO
</p>