QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#15979. Set Partition

Statistiques

Background

This is a homework problem assigned after the backtracking and branch-and-bound sections of an Algorithm Design and Analysis course. Xiao P could not solve it and asked Xiao T for help. Xiao T solved it instantly and significantly reduced the time complexity. To prove that you are better than Xiao T, you need to solve it as well.

Simplified problem statement:

Given a positive integer $n$, partition the set $\{1, 2, 3, \dots, n\}$ into several subsets $S_1, S_2, \dots, S_k$. You must ensure that if $x$ is assigned to a subset $S_i$, then $|S_i|$ must divide $x$. Additionally, you must minimize the number of subsets that contain exactly one element. If there are multiple valid partitions, any one of them is acceptable.

Input

The input contains multiple test cases.

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

For each test case, input a single line containing a positive integer $n$.

Output

For each test case:

Output a single line containing $n$ positive integers $s_1, s_2, \dots, s_n$, where $s_i$ represents the index of the subset that the number $i$ is assigned to.

Examples

Input 1

1
3

Output 1

1 2 3

Subtasks

For all test cases, it is guaranteed that $1 \le T \le 10^4$, $1 \le n \le 10^5$, and $1 \le \sum n \le 10^5$.

Note

Everyone is welcome to enroll in the Algorithm Design and Analysis (Experimental Class) offered by the School of Electronics Engineering and Computer Science at Peking University. You can learn many useful algorithmic concepts in this course, course code 04833060.

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.