#include<iostream>
using namespace std;
typedef struct Node
{
int data;
Node * next;
Node(int x)
{
data = x;
next = NULL;
}
}*LinkList;
void InitList(LinkList & list,int n)//初始化单循环链表,无头结点
{
Node * p,*q;
list = new Node(1);
q = p = list;
for(int i = 2;i <= n;i++)
{
Node * temp = new Node(i);
p->next = temp;
p = p->next;
}
p->next = q;
}
void count(LinkList list,int N)//计数并输出
{
Node * p = list;
while(N--)
{
Node * q = p->next->next;
cout << q->data << ' ';
p->next->next = q->next;
p = q->next;//p指向下次报数的位置
free(q);
}
cout << endl;
}
int main(void)
{
int m;
cin >> m;
while(m--)
{
int N;
cin >> N;
LinkList list;
InitList(list, N);
count(list, N);
}
return 0;
}
using namespace std;
typedef struct Node
{
int data;
Node * next;
Node(int x)
{
data = x;
next = NULL;
}
}*LinkList;
void InitList(LinkList & list,int n)//初始化单循环链表,无头结点
{
Node * p,*q;
list = new Node(1);
q = p = list;
for(int i = 2;i <= n;i++)
{
Node * temp = new Node(i);
p->next = temp;
p = p->next;
}
p->next = q;
}
void count(LinkList list,int N)//计数并输出
{
Node * p = list;
while(N--)
{
Node * q = p->next->next;
cout << q->data << ' ';
p->next->next = q->next;
p = q->next;//p指向下次报数的位置
free(q);
}
cout << endl;
}
int main(void)
{
int m;
cin >> m;
while(m--)
{
int N;
cin >> N;
LinkList list;
InitList(list, N);
count(list, N);
}
return 0;
}