//* Problem  : 2485 - Card Trick
//* Contest  : acm.tju.edu.cn
//* Origin   : Nordic_2006
//* Type     : Solution
//* Date     : 2007.08.26
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int a[14][14];
int n;

void next(int *pos, int n)
{
	pos[0] = (pos[0] + 1) % n;
	while (a[n][pos[0]]) pos[0] = (pos[0] + 1) % n;
}

void fill()
{
	int i, k, n, pos;
	for (n = 1; n <= 13; n++)
	{
		pos = -1;
		for (k = 1; k <= n; k++)
		{
			for (i = 0; i <= k; i++)
				next(&pos, n);
			a[n][pos] = k;
		}
	}
}

int main()
{
	fill();
	int i, nt;
	scanf("%d", &nt);
	while (nt--)
	{
		scanf("%d", &n);
		for (i = 0; i < n - 1; i++)
			printf("%d ",a[n][i]);
		printf("%d\n", a[n][i]);
	}
	return 0;
}