QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB

#21387. A Simple Construction Problem

Statistics

For a positive integer $n$, a sequence of length $n$ is called a “red-brick sequence” if it satisfies the following conditions:

  • Each of $1, 2, \ldots, n$ appears exactly once in the sequence.
  • The sum of every pair of adjacent elements is not a perfect square.

Given an integer $n$, construct a red-brick sequence of length $n$.

Input

The first line contains an integer $T$ ($1 \le T \le 10^4$), the number of test cases.

For each test case, the only line contains an integer $n$ ($1 \le n \le 4 \times 10^6$), the required length of the red-brick sequence.

It is guaranteed that the sum of $n$ does not exceed $4 \times 10^6$. It can be proved that a solution always exists under the given constraints.

Output

Output $T$ lines, each containing the sequence to be constructed. If there are multiple answers, output any of them.

Examples

Input 1

5
1
2
3
4
5

Output 1

1
1 2
1 2 3
1 2 3 4
1 4 2 3 5

Note

For $n = 5$, if the output sequence is 1 2 3 4 5, it is a wrong answer because $4 + 5 = 9$ is a perfect square.

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.