QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18678. Beautiful Sequence

統計

One of the problemsetters of this contest, a KSA student, has come to like prime numbers and decided that a sequence of length $N$ that satisfies all of the following conditions is called a beautiful sequence.

  • The sequence is a permutation of length $N$. In other words, each sequence element is in the range of $1,2,\cdots ,N$, and the elements are pairwise distinct.
  • The difference between two distinct elements that are a prime distance apart must also be a prime number. The distance between the $i$-th element and the $j$-th element is given by $|j-i|$.

Input

Each test contains multiple test cases. The first line contains an integer $T$, the number of test cases. The description of the test cases follows.

The first and only line of each test case contains an integer $N$.

Output

For each test case, if a beautiful sequence of length $N$ exists, print YES on the first line and the space-separated elements on the second line. If a beautiful sequence of length $N$ does not exist, print NO instead.

If there are multiple solutions, print any of them.

Constraints

  • $1\leq T \leq 100$
  • $3\leq N \leq 300$

Scoring

No. Points Constraints
1 16 $T = 1$; $N = 6$
2 84 No additional constraints

Examples

Input 1

2
5
7

Output 1

YES
2 1 5 4 3
YES
6 2 3 4 5 1 7

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.