You are given an array $a$ of length $n$ consisting of zeros. You perform $n$ actions with this array: during the $i$-th action, the following sequence of operations appears:  Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftmost one;  Let this segment be $[l; r]$. If $r-l+1$ is odd (not divisible by $2$) then assign (set) $a[\frac{l+r}{2}] := i$ (where $i$ is the number of the current action), otherwise (if $r-l+1$ is even) assign (set) $a[\frac{l+r-1}{2}] := i$. 

Consider the array $a$ of length $5$ (initially $a=[0, 0, 0, 0, 0]$). Then it changes as follows:  Firstly, we choose the segment $[1; 5]$ and assign $a[3] := 1$, so $a$ becomes $[0, 0, 1, 0, 0]$;  then we choose the segment $[1; 2]$ and assign $a[1] := 2$, so $a$ becomes $[2, 0, 1, 0, 0]$;  then we choose the segment $[4; 5]$ and assign $a[4] := 3$, so $a$ becomes $[2, 0, 1, 3, 0]$;  then we choose the segment $[2; 2]$ and assign $a[2] := 4$, so $a$ becomes $[2, 4, 1, 3, 0]$;  and at last we choose the segment $[5; 5]$ and assign $a[5] := 5$, so $a$ becomes $[2, 4, 1, 3, 5]$. 

Your task is to find the array $a$ of length $n$ after performing all $n$ actions. Note that the answer exists and unique.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Then $t$ test cases follow.

The only line of the test case contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the length of $a$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$).


-----Output-----

For each test case, print the answer — the array $a$ of length $n$ after performing $n$ actions described in the problem statement. Note that the answer exists and unique.


-----Example-----
Input
6
1
2
3
4
5
6

Output
1 
1 2 
2 1 3 
3 1 2 4 
2 4 1 3 5 
3 4 1 5 2 6

Difficulty: MEDIUM_HARD
Tags: Sorting

Data structures

Constructive algorithms
Skill types: Sorting

Data structures

Starter code:

Solutions:
def generate(l, n):
	if n <= 0:
		return
	if n == 1:
		d.append((l, 1, l))
		return
	elif n % 2 == 1:
		d.append((l, n, l + (n - 1) // 2))
		generate(l, (n - 1) // 2)
		generate(l + (n - 1) // 2 + 1, (n - 1) // 2)
	else:
		d.append((l, n, l + (n - 1) // 2))
		generate(l, (n - 1) // 2)
		generate(l + n // 2, (n - 1) // 2 + 1)
t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	n = int(input())
	a = [0] * n
	d = []
	generate(0, n)
	d = sorted(d, key=lambda l: (l[1], -l[0]), reverse=True)
	i = 1
	for elem in d:
		a[elem[2]] = i
		i += 1
	print(' '.join((str(i) for i in a)))


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
input = sys.stdin.readline
import bisect
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))

def res(a, b):
	if (a + b) % 2 == 1:
		return (a + b - 1) // 2
	else:
		return (a + b) // 2
t = int(input())
for _ in range(0, t):
	n = int(input())
	q = []
	ans = [0] * (n + 1)
	heapq.heapify(q)
	x = res(1, n)
	heapq.heappush(q, [-(n - 1), 1, n])
	c = 1
	while len(q) != 0:
		a = heapq.heappop(q)
		x = res(a[1], a[2])
		ans[x] = c
		c = c + 1
		if a[1] != a[2] and a[1] <= x - 1:
			heapq.heappush(q, [-(x - 1 - a[1]), a[1], x - 1])
		if a[1] != a[2] and a[2] >= x + 1:
			heapq.heappush(q, [-(a[2] - x - 1), x + 1, a[2]])
	print(*ans[1:])


import heapq
t = int(input())
for loop in range(t):
	n = int(input())
	q = []
	q.append([-1 * n, 0, n - 1])
	ans = [0] * n
	cnt = 1
	while len(q) > 0:
		tmppop = heapq.heappop(q)
		(length, l, r) = tmppop
		mid = (l + r) // 2
		ans[mid] = cnt
		cnt += 1
		if mid - 1 >= l:
			heapq.heappush(q, [-1 * (mid - 1 - l + 1), l, mid - 1])
		if mid + 1 <= r:
			heapq.heappush(q, [-1 * (r - (mid + 1) + 1), mid + 1, r])
	print(*ans)


(i, j, mn) = (1, 2, [])

def ms(l, l1, r, x):
	global i, j
	if l1 <= r:
		m = (l1 + r) // 2
		mn.append((l1, r))
		l[m] = i
		i += 1
		ms(l, l1, m - 1, 1)
		ms(l, m + 1, r, 0)
	return mn
for _ in range(int(input())):
	(i, mn, n) = (1, [], int(input()))
	l = [0] * n
	a = ms(l, 0, n - 1, 1)
	a.sort(key=lambda x: -(x[1] - x[0]))
	for i in range(n):
		l[(a[i][0] + a[i][1]) // 2] = i + 1
	print(' '.join(list(map(str, l))))


from heapq import *
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	hq = [(-n, 0, n - 1)]
	for i in range(1, n + 1):
		(_, l, r) = heappop(hq)
		m = (l + r) // 2
		a[m] = i
		if m > l:
			heappush(hq, (l - m, l, m - 1))
		if m < r:
			heappush(hq, (m - r, m + 1, r))
	print(*a)


from sys import stdin, stdout
import math
from collections import defaultdict
import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	val = [0] * n
	heapq.heappush(a, (-n, (0, n - 1)))
	i = 1
	while a:
		arr = heapq.heappop(a)[1]
		idx = (arr[0] + arr[1]) // 2
		val[idx] = i
		lft = (arr[0], idx - 1)
		rgt = (idx + 1, arr[1])
		if arr[0] <= idx - 1:
			heapq.heappush(a, (-idx + arr[0], lft))
		if idx + 1 <= arr[1]:
			heapq.heappush(a, (idx - arr[1], rgt))
		i += 1
	print(*val)


import sys
input = sys.stdin.readline
from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	d = []
	q = deque()
	q.append([1, n])
	while q:
		(l, r) = q.popleft()
		if l <= r:
			m = (l + r) // 2
			d.append([-(r - l + 1), l, m])
			if m - 1 >= l:
				q.append([l, m - 1])
			if r >= m + 1:
				q.append([m + 1, r])
	d = sorted(d, key=lambda x: (x[0], x[1]))
	ans = [0] * (n + 1)
	for i in range(1, n + 1):
		m = d[i - 1][2]
		ans[m] = i
	sys.stdout.write(' '.join(map(str, ans[1:])) + '\n')


from heapq import heapify, heappush, heappop
for _ in range(int(input())):
	n = int(input())
	q = []
	heappush(q, (-n, 0, n - 1))
	a = [0] * n
	i = 1
	while len(q):
		(x, l, r) = heappop(q)
		m = (l + r) // 2
		a[m] = i
		i += 1
		if l != m:
			heappush(q, (l - m, l, m - 1))
		if r != m:
			heappush(q, (m - r, m + 1, r))
	for i in a:
		print(i, end=' ')
	print()


import heapq
t = int(input())
while t > 0:
	n = int(input())
	arr = [0 for _ in range(n)]
	q = [(-1 * n, 0, n - 1)]
	heapq.heapify(q)
	ct = 1
	while len(q) > 0:
		cur = heapq.heappop(q)
		l = cur[1]
		r = cur[2]
		if l > r:
			continue
		mid = (l + r) // 2
		arr[mid] = ct
		ct += 1
		if mid - 1 >= 0 and mid - 1 >= l:
			heapq.heappush(q, (-1 * (mid - 1 - l + 1), l, mid - 1))
		if mid + 1 < n and r >= mid + 1:
			heapq.heappush(q, (-1 * (r - (mid + 1) + 1), mid + 1, r))
	print(' '.join([str(x) for x in arr]))
	t -= 1


import math
import heapq as heap
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(1)
	elif n == 2:
		print(1, 2)
	else:
		l = [0] * (n + 1)
		h = []
		heap.heappush(h, [-n, 1])
		cur = 1
		while h:
			t = heap.heappop(h)
			(st, en) = (t[1], t[1] - t[0] - 1)
			mid = (st + en) // 2
			l[mid] = cur
			cur += 1
			if mid - 1 >= st and st != en:
				heap.heappush(h, [-(mid - 1 - st + 1), st])
			if mid + 1 <= en and st != en:
				heap.heappush(h, [-(en - (mid + 1) + 1), mid + 1])
		for i in range(1, n + 1):
			print(l[i], end=' ')
		print()


from heapq import *
nc = int(input())
for c in range(nc):
	n = int(input())
	(a, h) = ([0 for i in range(n)], [])
	heappush(h, (-n, 0, n))
	i = 1
	while len(h) > 0:
		(s, l, r) = heappop(h)
		s *= -1
		if s % 2 == 0:
			m = (l + r) // 2 - 1
		else:
			m = (l + r) // 2
		a[m] = str(i)
		i += 1
		if l < m:
			heappush(h, (-(m - l), l, m))
		if m + 1 < r:
			heappush(h, (-(r - m - 1), m + 1, r))
	print(' '.join(a))


import math as mt
import sys, string
input = sys.stdin.readline
import collections
from heapq import heappush, heapify, heappop
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	n = I()
	l = [0] * n
	r = [[-n - 1, 0, n - 1]]
	heapify(r)
	for i in range(1, n + 1):
		(size, left, right) = heappop(r)
		mid = (left + right) // 2
		l[mid] = i
		if mid - 1 - left >= 0:
			heappush(r, [left - mid + 1, left, mid - 1])
		if right - mid - 1 >= 0:
			heappush(r, [mid + 1 - right, mid + 1, right])
	print(*l)


import heapq as h

class my_class(object):

	def __init__(self, l, r):
		self.l = l
		self.r = r
		self.len = -(r - l + 1)

	def __lt__(self, other):
		if self.len == other.len:
			return self.l < other.l
		return self.len < other.len

	def __repr__(self):
		return f'({self.l} - {self.r})'
for _ in range(int(input())):
	n = int(input())
	a = [my_class(0, n - 1)]
	ans = [-1] * n
	i = 1
	while a:
		rmv = h.heappop(a)
		(l, r) = (rmv.l, rmv.r)
		mid = l + r >> 1
		if ans[mid] != -1:
			continue
		ans[mid] = i
		i += 1
		if l < r:
			h.heappush(a, my_class(l, mid - 1))
			h.heappush(a, my_class(mid + 1, r))
	print(*ans)


from heapq import heappush, heappop, heapify

def calc(n):
	ll = []
	heapify(ll)
	c = 1
	res = [0] * (n + 1)
	heappush(ll, (-n, (1, n)))
	while ll:
		q = heappop(ll)
		l = q[1][0]
		r = q[1][1]
		m = (l + r) // 2
		res[m] = c
		c += 1
		if l == r:
			continue
		if l < m:
			heappush(ll, (-(m - l), (l, m - 1)))
		if r > m:
			heappush(ll, (-(r - m), (m + 1, r)))
	return res[1:]
t = int(input())
while t:
	n = int(input())
	print(*calc(n))
	t -= 1


mod = int(1000000000.0) + 7
import heapq

def ip():
	return int(input())

def Ip():
	return map(int, input().split())
for _ in range(0, int(input())):
	n = int(input())
	if n == 1:
		print('1')
	elif n == 2:
		print('1 2')
	else:
		l = [0] * n
		t = n // 2 - (n % 2 == 0)
		l[t] = 1
		t -= 1
		x = []
		c = 2
		heapq.heapify(x)
		heapq.heappush(x, [-(t + 1), 0, t])
		heapq.heappush(x, [-(n - t - 2), t + 2, n - 1])
		while c <= n:
			el = heapq.heappop(x)
			(i, j) = (el[1], el[2])
			if (j - i + 1) % 2 == 1:
				t = (i + j) // 2
				l[t] = c
			else:
				t = (i + j - 1) // 2
				l[t] = c
			if j - i > 1:
				heapq.heappush(x, [i - t, i, t - 1])
				heapq.heappush(x, [t - j, t + 1, j])
			elif j - i == 1:
				heapq.heappush(x, [-1, j, j])
			c += 1
		for i in l:
			print(i, end=' ')
		print()


from sys import stdin
import heapq
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = [0] * n
	q = [(-1 * n, 0, n - 1)]
	heapq.heapify(q)
	i = 1
	while q:
		(siz, l, r) = heapq.heappop(q)
		mid = l + r >> 1
		a[mid] = i
		i += 1
		if r != mid:
			heapq.heappush(q, (mid - r, mid + 1, r))
		if l != mid:
			heapq.heappush(q, (l - mid, l, mid - 1))
	print(*a)


import sys
from math import ceil, sqrt
read = sys.stdin.buffer.readline
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())

def isp(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
primes = []
for _ in range(cin()):
	n = cin()
	li = []

	def fn(l, r):
		if r < l:
			li.append('none')
		if l == r:
			li.append([l, r, -1])
		else:
			li.append([l, r, -(r - l + 1)])
			ln = r - l + 1
			mid = (l + r) // 2
			if mid - 1 >= l:
				fn(l, mid - 1)
			if mid + 1 <= r:
				fn(mid + 1, r)
	fn(0, n - 1)
	li.sort(key=lambda x: (x[2], x[0]))
	a = [0] * n
	for i in range(n):
		(l, r) = (li[i][0], li[i][1])
		a[(l + r) // 2] = i + 1
	for el in a:
		print(el, end=' ')
	print()


from heapq import *
a = int(input())
import sys
input = sys.stdin.readline
for i in range(a):
	x = int(input())
	ram = []
	heappush(ram, (-1 * x, 0, x - 1))
	ans = [0 for i in range(x)]
	count = 0
	while count < x:
		temp = heappop(ram)
		ans[(abs(temp[1]) + temp[2]) // 2] = count + 1
		siz = abs(temp[0])
		kem = abs(temp[1])
		count += 1
		if siz % 2 == 1:
			heappush(ram, (-1 * (siz // 2), temp[1], kem + siz // 2 - 1))
			heappush(ram, (-1 * (siz // 2), kem + siz // 2 + 1, temp[2]))
		else:
			heappush(ram, (-1 * (siz // 2), (abs(temp[1]) + temp[2]) // 2 + 1, temp[2]))
			if siz // 2 > 1:
				heappush(ram, (-1 * (siz // 2 - 1), temp[1], (kem + temp[2]) // 2 - 1))
	print(*ans)


import sys
import heapq
input = sys.stdin.buffer.readline

def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	n = int(input())
	li = [(-n, 0, n - 1)]
	heapq.heapify(li)
	arr = [-1] * n
	c = 1
	while li:
		(x, l, r) = heapq.heappop(li)
		x = -x
		idx = (l + r) // 2
		arr[idx] = c
		c += 1
		if idx > l:
			heapq.heappush(li, (-(idx - 1 - l + 1), l, idx - 1))
		if idx < r:
			heapq.heappush(li, (-(r - idx), idx + 1, r))
	print(*arr)


import sys
input = sys.stdin.buffer.readline
import heapq

def solution():
	for _ in range(int(input())):
		n = int(input())
		a = [0] * n
		h = [(-n, (0, n - 1))]
		i = 1
		while i <= n:
			(len, (l, r)) = heapq.heappop(h)
			mid = (l + r) // 2
			a[mid] = i
			heapq.heappush(h, (-(mid - l), (l, mid - 1)))
			heapq.heappush(h, (-(r - mid), (mid + 1, r)))
			i += 1
		for i in a:
			print(i, end=' ')
		print()
solution()


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * n
	heap = []
	l = 0
	r = n - 1
	heap.append((l - r, l))
	for i in range(1, n + 1):
		(a, l) = heapq.heappop(heap)
		r = l - a
		m = (l + r) // 2
		arr[m] = i
		(l1, r1) = (l, m - 1)
		(l2, r2) = (m + 1, r)
		if l1 <= r1:
			heapq.heappush(heap, (l1 - r1, l1))
		if l2 <= r2:
			heapq.heappush(heap, (l2 - r2, l2))
	print(' '.join([str(x) for x in arr]))


from collections import defaultdict as dc
from collections import Counter
from heapq import *
import math
from bisect import bisect_left, bisect
import sys
from collections import deque as dq
from heapq import heapify, heappush, heappop
mod = 10 ** 9 + 7

def sinp():
	p = str(input())
	return p

def seive(n):
	p = [0] * (n + 1)
	for i in range(2, n):
		if p[i] == 0:
			for j in range(2 * i, n + 1, i):
				p[i] = 1
	return p

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def solve(n):
	z = 1
	a = [0] * n
	q = []
	q.append([-n + 1, 0])
	heapify(q)
	while len(q):
		(p, l) = heappop(q)
		r = l - p
		mid = (l + r) // 2
		a[mid] = z
		z += 1
		if l <= mid - 1:
			heappush(q, [l - mid + 1, l])
		if r >= mid + 1:
			heappush(q, [mid + 1 - r, mid + 1])
	return a
for test in range(inp()):
	n = inp()
	l = solve(n)
	print(*l)


import sys, heapq
from math import floor

def length(i, j):
	return j - i + 1

def neg_len(i, j):
	return -length(i, j)
lines = sys.stdin.readlines()
t = int(lines[0])
for i in range(1, t + 1):
	n = int(lines[i])
	q = [(neg_len(1, n), 1, n)]
	i = 0
	a = ['0'] * n
	while i < n:
		curr = heapq.heappop(q)
		curr_split = floor((curr[1] + curr[2]) / 2)
		heapq.heappush(q, (neg_len(curr[1], curr_split - 1), curr[1], curr_split - 1))
		heapq.heappush(q, (neg_len(curr_split + 1, curr[2]), curr_split + 1, curr[2]))
		a[curr_split - 1] = str(i + 1)
		i += 1
	print(' '.join(a))


import heapq
t = int(input())
while t:
	n = int(input())
	ans = [0 for i in range(n)]
	h = [(-n + 1, 0, n - 1)]
	for i in range(n):
		(L, l, r) = heapq.heappop(h)
		index = l + (r - l) // 2
		ans[index] = i + 1
		if index + 1 <= r:
			heapq.heappush(h, (index + 1 - r, index + 1, r))
		if l <= index - 1:
			heapq.heappush(h, (l - index + 1, l, index - 1))
	for x in ans:
		print(x, end=' ')
	print()
	t -= 1


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	d = {}
	d[n] = []
	heapq.heapify(d[n])
	heapq.heappush(d[n], 1)
	l = [0] * (n + 1)
	m = 1
	c = n
	p = []
	heapq.heapify(p)
	while True:
		while d[c]:
			x = heapq.heappop(d[c])
			y = x + n - 1
			if c % 2:
				e = x + c // 2
				l[e] = m
				m += 1
				try:
					heapq.heappush(d[c // 2], x)
					heapq.heappush(d[c // 2], e + 1)
				except:
					d[c // 2] = []
					heapq.heapify(d[c // 2])
					heapq.heappush(d[c // 2], x)
					heapq.heappush(d[c // 2], e + 1)
				if c // 2 >= 1:
					heapq.heappush(p, -1 * (c // 2))
			else:
				e = x + c // 2 - 1
				l[e] = m
				m += 1
				try:
					heapq.heappush(d[c // 2 - 1], x)
				except:
					d[c // 2 - 1] = []
					heapq.heapify(d[c // 2 - 1])
					heapq.heappush(d[c // 2 - 1], x)
				try:
					heapq.heappush(d[c // 2], e + 1)
				except:
					d[c // 2] = []
					heapq.heapify(d[c // 2])
					heapq.heappush(d[c // 2], e + 1)
				if c // 2 >= 1:
					heapq.heappush(p, -1 * (c // 2))
				if c // 2 - 1 > 0:
					heapq.heappush(p, -1 * (c // 2 - 1))
		if p:
			c = heapq.heappop(p)
			c = c * -1
		else:
			break
	del l[0]
	print(*l)


import heapq as hq
t = int(input())

def solve():
	n = int(input())
	a = [(-n, 0, n - 1)]
	count = 1
	ans = [0] * n
	while len(a) and count < n + 1:
		(size, l, r) = hq.heappop(a)
		if l > r:
			continue
		if l == r:
			ans[l] = count
			count += 1
		elif (r - l + 1) % 2 == 1:
			mid = (l + r) // 2
			ans[mid] = count
			count += 1
			hq.heappush(a, (-1 * (mid - l), l, mid - 1))
			hq.heappush(a, (-1 * (r - mid), mid + 1, r))
		else:
			mid = (l + r - 1) // 2
			ans[mid] = count
			count += 1
			hq.heappush(a, (-1 * (mid - l), l, mid - 1))
			hq.heappush(a, (-1 * (r - mid), mid + 1, r))
	print(*ans)
while t:
	solve()
	t -= 1


def solve(a, l, r):
	if r < l:
		return 0
	mid = (l + r) // 2
	a.append([mid, l, r])
	solve(a, mid + 1, r)
	solve(a, l, mid - 1)

def comp(x):
	return 200000 * (x[2] - x[1] + 1) + 100005 - x[1]
for _ in range(int(input())):
	n = int(input())
	ans = []
	solve(ans, 0, n - 1)
	ans = sorted(ans, key=comp, reverse=True)
	a = [0] * n
	for i in range(len(ans)):
		a[ans[i][0]] = i + 1
	print(*a)


import sys
import math
from collections import defaultdict, deque
import heapq
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	arr = [0] * (n + 1)
	heap = []
	heapq.heapify(heap)
	heapq.heappush(heap, [-n, 1, n])
	cur = 1
	while heap:
		(size, i, j) = heapq.heappop(heap)
		if i == j:
			arr[i] = cur
			cur += 1
			continue
		if (j - i + 1) % 2 == 0:
			mid = (j + i - 1) // 2
			arr[mid] = cur
			if mid + 1 <= j:
				heapq.heappush(heap, [-(j - mid), mid + 1, j])
			if i <= mid - 1:
				heapq.heappush(heap, [-(mid - 1 - i + 1), i, mid - 1])
			cur += 1
		else:
			mid = (j + i) // 2
			arr[mid] = cur
			if i <= mid - 1:
				heapq.heappush(heap, [-(mid - 1 - i + 1), i, mid - 1])
			if mid + 1 <= j:
				heapq.heappush(heap, [-(j - mid - 1 + 1), mid + 1, j])
			cur += 1
	print(*arr[1:])


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0 for _ in range(n)]
	q = []
	heapq.heappush(q, (-n, 0))
	for i in range(n):
		(zeros, left) = heapq.heappop(q)
		right = left - zeros - 1
		if zeros % 2 == 1:
			idx = (left + right) // 2
			left_zeros = (zeros + 1) // 2
		else:
			idx = (left + right - 1) // 2
			left_zeros = (zeros + 2) // 2
		right_zeros = (zeros + 1) // 2
		arr[idx] = str(i + 1)
		if left_zeros != 0 and idx != 0:
			heapq.heappush(q, (left_zeros, left))
		if right_zeros != 0:
			heapq.heappush(q, (right_zeros, idx + 1))
	print(' '.join(arr))


from sys import *
import heapq
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	li = [0] * n
	h = []
	heapq.heappush(h, (-n, 0, n - 1))
	count = 1
	while h:
		tup = heapq.heappop(h)
		(length, l, r) = tup
		index = (l + r) // 2
		if r - index > 0:
			heapq.heappush(h, (-(r - index), index + 1, r))
		if index - l > 0:
			heapq.heappush(h, (-(index - l), l, index - 1))
		li[index] = count
		count += 1
	print(*li)


import collections
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	d = collections.deque()
	ans = [[1, n]]
	d.append([1, n])
	for i in range(1, n + 1):
		s = d.popleft()
		r = s[1]
		l = s[0]
		if (r - l + 1) % 2 == 1:
			a[(l + r) // 2 - 1] = i
			if r - l == 1:
				d.append([(l + r) // 2 + 1, r])
				ans.append([(l + r) // 2 + 1, r])
			elif r - l >= 2:
				d.append([l, (l + r) // 2 - 1])
				ans.append([l, (l + r) // 2 - 1])
				d.append([(l + r) // 2 + 1, r])
				ans.append([(l + r) // 2 + 1, r])
		else:
			a[(l + r - 1) // 2 - 1] = i
			if r - l == 1:
				d.append([(l + r) // 2 + 1, r])
				ans.append([(l + r) // 2 + 1, r])
			elif r - l >= 2:
				d.append([(l + r) // 2 + 1, r])
				ans.append([(l + r) // 2 + 1, r])
				d.append([l, (l + r) // 2 - 1])
				ans.append([l, (l + r) // 2 - 1])
	ans.sort(key=lambda x: (-(x[1] - x[0]), x[0]))
	k = 1
	for i in ans:
		r = i[1]
		l = i[0]
		if (r - l + 1) % 2 == 1:
			a[(l + r) // 2 - 1] = k
		else:
			a[(l + r - 1) // 2 - 1] = k
		k += 1
	print(*a)


import heapq

def rlen(r, l):
	return r - l

def solve(v):
	l = 1
	r = v
	out = [0 for x in range(v)]
	q = [(-rlen(r, l), l, r)]
	heapq.heapify(q)
	i = 1
	while q != []:
		top = heapq.heappop(q)
		(_, l, r) = top
		mx = r - l + 1
		mj = 0
		if mx % 2 == 0:
			mj = (l + r - 1) // 2
		else:
			mj = (l + r) // 2
		out[mj - 1] = i
		i += 1
		if mj - 1 > 0 and mj - 1 >= l:
			heapq.heappush(q, (-rlen(mj - 1, l), l, mj - 1))
		if mj + 1 <= v and mj + 1 <= r:
			heapq.heappush(q, (-rlen(r, mj + 1), mj + 1, r))
	print(' '.join(map(str, out)))
t = int(input())
while t > 0:
	n = int(input())
	solve(n)
	t -= 1


from heapq import heappush, heapify, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	q = [[-n - 1, 0, n - 1]]
	heapify(q)
	for i in range(1, n + 1):
		(p, l, r) = heappop(q)
		k = (r + l) // 2
		a[k] = i
		if k - 1 - l >= 0:
			heappush(q, [l - k + 1, l, k - 1])
		if r - k - 1 >= 0:
			heappush(q, [k + 1 - r, k + 1, r])
	print(*a)


import heapq
TT = int(input())
for _ in range(TT):
	n = int(input())
	ans = [0] * n
	l = 0
	r = n - 1
	li = [(-(r - l + 1), l, r)]
	heapq.heapify(li)
	ctr = 1
	while len(li):
		(llen, l, r) = heapq.heappop(li)
		if llen % 2 == 0:
			sp = (l + r - 1) // 2
		else:
			sp = (l + r) // 2
		llen = sp - 1 - l + 1
		if llen > 0:
			heapq.heappush(li, (-llen, l, sp - 1))
		rlen = r - (sp + 1) + 1
		if rlen > 0:
			heapq.heappush(li, (-rlen, sp + 1, r))
		ans[sp] = str(ctr)
		ctr += 1
	print(' '.join(ans))


def func1(l, r):
	if l > r:
		return
	m = (l + r) // 2
	li1[m] = [l - r, m]
	func1(l, m - 1)
	func1(m + 1, r)
a = int(input())
for _ in range(a):
	x = int(input())
	(li1, li2) = ([0] * x, [0] * x)
	func1(0, x - 1)
	li1.sort()
	i = 0
	for j in li1:
		li2[j[1]] = i + 1
		i += 1
	print(*li2)


from sys import stdin, exit, setrecursionlimit
from collections import deque
from heapq import *
from math import gcd
from math import ceil, log2
setrecursionlimit(10000000)
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	n = int(input())
	arr = [0] * n
	q = []
	heappush(q, (n - 1, 0, n - 1))
	val = 1
	while q:
		(tmp, l, r) = heappop(q)
		if l > r:
			continue
		arr[(r + l) // 2] = val
		val += 1
		if l == r:
			continue
		heappush(q, (-((r + l) // 2 - l), l, (r + l) // 2 - 1))
		heappush(q, (-(r - (r + l) // 2), (r + l) // 2 + 1, r))
	print(*arr)


import sys
input = sys.stdin.readline
import heapq

def inp():
	return int(input().rstrip())

def inlt():
	return list(map(int, input().rstrip().split()))

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

def invr():
	return map(int, input().rstrip().split())
t = inp()
for _ in range(t):
	n = inp()
	ans = [0 for i in range(n)]
	q = [(-n, 0, n - 1)]
	turn = 1
	while q != []:
		(leng, left_in, right_in) = heapq.heappop(q)
		leng = -leng
		if leng <= 0:
			continue
		if leng % 2 == 0:
			mid_in = left_in + leng // 2 - 1
			ans[mid_in] = turn
			turn += 1
			if leng // 2 <= 0:
				continue
			heapq.heappush(q, (-max(leng // 2 - 1, 0), left_in, mid_in - 1))
			heapq.heappush(q, (-(leng // 2), mid_in + 1, right_in))
		else:
			mid_in = left_in + leng // 2
			ans[mid_in] = turn
			turn += 1
			if leng // 2 <= 0:
				continue
			heapq.heappush(q, (-(leng // 2), left_in, mid_in - 1))
			heapq.heappush(q, (-(leng // 2), mid_in + 1, right_in))
	print(*ans)


from heapq import heapify, heappop, heappush
for _ in range(int(input())):
	n = int(input())
	arr = [0] * n
	hp = []
	heapify(hp)
	heappush(hp, (-1 * n, 0, n - 1))
	start = 1
	while hp:
		(size, i, j) = heappop(hp)
		size = -1 * size
		pos = 0
		if size % 2 == 0:
			pos = (i + j - 1) // 2
		else:
			pos = (i + j) // 2
		arr[pos] = str(start)
		start += 1
		if i == j:
			continue
		if pos != i:
			heappush(hp, (i - pos, i, pos - 1))
		heappush(hp, (pos - j, pos + 1, j))
	print(' '.join(arr))


from sys import stdin, stdout
from collections import deque, defaultdict
from heapq import heappush, heappop
import math as m
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))

def main():
	T = int(rl())
	for _ in range(T):
		n = int(rl())
		A = [0 for _ in range(n)]
		H = []
		heappush(H, (-n, 0, n - 1))
		i = 1
		while H:
			(_, L, R) = heappop(H)
			x = R - L + 1
			mid = 0
			if x % 2 == 1:
				mid = (L + R) // 2
			else:
				mid = (L + R - 1) // 2
			A[mid] = i
			(NL, NR) = (L, mid - 1)
			NLEN = NR - NL + 1
			if NLEN > 0:
				heappush(H, (-NLEN, NL, NR))
			(ML, MR) = (mid + 1, R)
			MLEN = MR - ML + 1
			if MLEN > 0:
				heappush(H, (-MLEN, ML, MR))
			i += 1
		print(' '.join((str(x) for x in A)))
	stdout.close()
main()


from sys import stdin, stdout
import math
from collections import defaultdict
import heapq
import os
import sys
from io import BytesIO, IOBase

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = []
		val = [0] * n
		heapq.heapify(a)
		heapq.heappush(a, (-n, 0, n - 1))
		i = 1
		while a != []:
			arr = heapq.heappop(a)
			idx = (arr[1] + arr[2]) // 2
			val[idx] = i
			if arr[1] <= idx - 1:
				heapq.heappush(a, (-idx + arr[1], arr[1], idx - 1))
			if idx + 1 <= arr[2]:
				heapq.heappush(a, (idx - arr[2], idx + 1, arr[2]))
			i += 1
		print(*val)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, os
input = sys.stdin.buffer.read().split(b'\n')[::-1].pop
from heapq import heappush, heappop

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))

def print_array(a):
	(os.write(1, b' '.join((str(x).encode('ascii') for x in a))), os.write(1, b'\n'))

def binary(a, l, r, i):
	if (r - l + 1) % 2 == 1:
		return (l + r) // 2
	return (l + r - 1) // 2

def solve(a, l, r, i):
	ans = a
	tupla = (-len(a), 0, len(a) - 1, ans)
	a = []
	heappush(a, tupla)
	while len(a):
		(size, ini, fim, cur) = heappop(a)
		split = binary(cur, ini, fim, i)
		if ans[split] != 0:
			continue
		ans[split] = i
		left = ans[ini:split]
		right = ans[split + 1:fim + 1]
		if len(right) > len(left):
			if len(right) > 0:
				heappush(a, (-len(right), split + 1, fim, right))
			if len(left) > 0:
				heappush(a, (-len(left), ini, split - 1, left))
		else:
			if len(left) > 0:
				heappush(a, (-len(left), ini, split - 1, left))
			if len(right) > 0:
				heappush(a, (-len(right), split + 1, fim, right))
		i += 1
	return ans
t = ii()
for _ in range(t):
	n = ii()
	a = [0] * n
	a = solve(a, 0, n - 1, 1)
	print_array(a)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	output = [0] * n
	Q = [(-n, 0, n - 1)]
	for i in range(1, n + 1):
		prev = heapq.heappop(Q)
		(lo, hi) = (prev[1], prev[2])
		mid = (lo + hi) // 2
		output[mid] = i
		if mid > lo:
			heapq.heappush(Q, (-(mid - 1 - lo), lo, mid - 1))
		if hi > mid:
			heapq.heappush(Q, (-(hi - 1 - mid), mid + 1, hi))
	print(*output)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


from heapq import *
for _ in range(int(input())):
	n = int(input())
	lt = [0] * n
	ql = []
	heappush(ql, (-n, 0, n - 1))
	i = 1
	for i in range(1, n + 1):
		t = heappop(ql)
		(l, r) = (t[1], t[2])
		mid = (l + r) // 2
		lt[mid] = i
		(ll, lr, llen) = (l, mid - 1, mid - l)
		(rl, rr, rlen) = (mid + 1, r, r - mid)
		if rlen > 0:
			heappush(ql, (-rlen, rl, rr))
		if llen > 0:
			heappush(ql, (-llen, ll, lr))
	print(*lt)


from collections import *
from heapq import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	n = ri()
	out = [0] * n
	q = []
	heappush(q, (-n, 0))
	curr = 0
	while q:
		curr += 1
		nex = heappop(q)
		length = -nex[0]
		start = nex[1]
		if length % 2:
			out[start + length // 2] = curr
			if length // 2:
				heappush(q, (-(length // 2), start))
				heappush(q, (-(length // 2), start + length // 2 + 1))
		else:
			half = length // 2
			out[start + length // 2 - 1] = curr
			heappush(q, (-(length // 2), start + length // 2))
			if length > 2:
				heappush(q, (-(length // 2 - 1), start))
	print(*out)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import heapq
t = int(input())
for i in range(t):
	n = int(input())
	arr = [[-1 * n, 0]]
	ans = [0] * n
	j = 1
	s = 0
	while s < n and arr[0][0] != 0:
		lis = heapq.heappop(arr)
		temp = abs(lis[0])
		l = lis[1]
		if temp % 2 == 0:
			ans[l + temp // 2 - 1] = j
			if temp != 2:
				heapq.heappush(arr, [-1 * (temp // 2 - 1), l])
				heapq.heappush(arr, [-1 * (temp // 2), l + temp // 2])
			else:
				heapq.heappush(arr, [0, l])
				heapq.heappush(arr, [-1 * (temp // 2), l + temp // 2])
				s += 1
		else:
			ans[l + temp // 2] = j
			if temp != 1:
				heapq.heappush(arr, [-1 * (temp // 2), l])
				heapq.heappush(arr, [-1 * (temp // 2), l + temp // 2 + 1])
			else:
				heapq.heappush(arr, [0, l])
				s += 1
		j += 1
	print(' '.join((str(x) for x in ans)))


import sys

def answer(n):
	ans = [0 for _ in range(n)]
	stack = [(0, n - 1)]
	buckets = [[] for _ in range(n + 1)]
	largest_b = 0
	for i in range(n):
		tup = stack.pop()
		l = tup[0]
		r = tup[1]
		mid = (l + r) // 2
		w = r - l + 1
		buckets[w].append(mid)
		if mid - 1 >= l:
			stack.append((l, mid - 1))
		if r >= mid + 1:
			stack.append((mid + 1, r))
	ctr = 1
	for i in range(n, 0, -1):
		if not buckets[i]:
			continue
		buckets[i].sort()
		for midpoint in buckets[i]:
			ans[midpoint] = ctr
			ctr += 1
	return ans

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		print(*answer(n))
		t -= 1
	return
main()


t = int(input())

def d(l, r):
	if l > r:
		return
	m = (l + r) // 2
	a[m] = (l - r, m)
	d(l, m - 1)
	d(m + 1, r)
for _ in range(t):
	n = int(input())
	a = [0] * n
	b = [0] * n
	d(0, n - 1)
	for (i, j) in enumerate(sorted(a)):
		b[j[1]] = i + 1
	print(*b)


import heapq
for t in range(int(input())):
	n = int(input())
	ans = [0] * n
	a = []
	heapq.heapify(a)
	heapq.heappush(a, (-n, 0, n - 1))
	for i in range(1, n + 1):
		cur = heapq.heappop(a)
		index = (cur[1] + cur[2]) // 2
		ans[index] = i
		p1 = index - cur[1]
		p2 = cur[2] - index
		heapq.heappush(a, (-p1, cur[1], index - 1))
		heapq.heappush(a, (-p2, index + 1, cur[2]))
	print(*ans)


from heapq import *
t = int(input())
for t1 in range(t):
	n = int(input())
	if n == 1:
		print(1)
		continue
	a = [0] * n
	q = [(0, n - 1)]
	heapify(q)
	i = 0
	while len(q) != 0:
		(l, r) = heappop(q)
		mid = (l + r) // 2
		i += 1
		a[mid] = (mid, l - r)
		if mid - 1 >= l:
			heappush(q, (l, mid - 1))
		if r >= mid + 1:
			heappush(q, (mid + 1, r))
	b = [0] * n
	a.sort(key=lambda x: x[1])
	o = 0
	for p in a:
		o += 1
		b[p[0]] = o
	print(*b)


import heapq
for T in range(int(input())):
	n = int(input())
	arr = [0] * (n + 1)
	min_heap = [(-n, 1)]
	i = 1
	while min_heap:
		(l, st) = heapq.heappop(min_heap)
		l = -l
		m = st + (l - 1) // 2
		arr[m] = i
		i += 1
		if m - st > 0:
			heapq.heappush(min_heap, (-(m - st), st))
		if l + st - m - 1 > 0:
			heapq.heappush(min_heap, (-(l + st - m - 1), m + 1))
	print(*arr[1:])


def func(a, b):
	if a > b:
		return
	mid = (a + b) // 2
	c.append([b - a, -1 * a])
	func(mid + 1, b)
	func(a, mid - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * n
	c = []
	func(0, n - 1)
	c = sorted(c, reverse=True)
	for i in range(n):
		d = c[i][0] // 2 - c[i][1]
		arr[d] = i + 1
	print(*arr)


import heapq

def func(n):
	q = []
	heapq.heappush(q, [-(n - 1 + 1), 1, n])
	i = 1
	q.append([1, n])
	while i <= n:
		y = heapq.heappop(q)
		mid = (y[1] + y[2]) // 2
		last = -y[0]
		a[mid] = i
		i += 1
		if last == 1:
			continue
		if mid - 1 >= y[1]:
			heapq.heappush(q, [-(mid - 1 - y[1] + 1), y[1], mid - 1])
		if mid + 1 <= y[2]:
			heapq.heappush(q, [-(y[2] - mid - 1 + 1), mid + 1, y[2]])
for _ in range(int(input())):
	n = int(input())
	a = [0] * (n + 1)
	func(n)
	print(*a[1:])


t = int(input())
import heapq
for i in range(t):
	n = int(input())
	a = [0 for j in range(n)]
	ls = [-1, n]
	hint = [(-n, -1, n)]
	heapq.heapify(hint)
	for j in range(n):
		interval = heapq.heappop(hint)
		if interval[0] % 2 == 0:
			ind = (interval[2] + interval[1] - 1) // 2
		else:
			ind = (interval[2] + interval[1]) // 2
		a[ind] = j + 1
		heapq.heappush(hint, (-(ind - interval[1] - 1), interval[1], ind))
		heapq.heappush(hint, (-(interval[2] - ind - 1), ind, interval[2]))
	print(' '.join([str(j) for j in a]))


import heapq
test = int(input())
for _ in range(test):
	n = int(input())
	heap = []
	heapq.heappush(heap, (-n, 1, n))
	ans = [0] * (n + 1)
	it = 1
	while len(heap):
		(l, s, e) = heapq.heappop(heap)
		if abs(l) % 2:
			mid = (s + e) // 2
		else:
			mid = (s + e - 1) // 2
		ans[mid] = it
		it += 1
		if mid - s > 0:
			i1 = (-(mid - s), s, mid - 1)
			heapq.heappush(heap, i1)
		if e - mid > 0:
			i2 = (-(e - mid), mid + 1, e)
			heapq.heappush(heap, i2)
	for i in ans[1:]:
		print(i, end=' ')
	print()


import heapq
t = int(input())
for i in range(t):
	n = int(input())
	ans = [0] * n
	h = []
	heapq.heappush(h, [-n, 0, n - 1])
	count = 1
	while count < n + 1:
		(s, l, r) = heapq.heappop(h)
		if (r - l + 1) % 2 == 1:
			m = (l + r) // 2
			ans[m] = count
			if (s + 1) // 2 != 0:
				heapq.heappush(h, [(s + 1) // 2, l, m - 1])
				heapq.heappush(h, [(s + 1) // 2, m + 1, r])
		else:
			m = (l + r - 1) // 2
			ans[m] = count
			if (s + 1) // 2 + 1 != 0:
				heapq.heappush(h, [(s + 1) // 2 + 1, l, m - 1])
			if (s + 1) // 2 != 0:
				heapq.heappush(h, [s // 2, m + 1, r])
		count += 1
	print(*ans)


import heapq
t = int(input())
for i in range(t):
	n = int(input())
	b = [0] * n
	l = [(-n, 0)]
	heapq.heapify(l)
	s = 1
	while l != []:
		(p, i) = heapq.heappop(l)
		p = -p
		if p % 2 == 0:
			r = p // 2 - 1
		else:
			r = p // 2
		if b[i + r] == 0:
			b[i + r] = s
		if p > 1:
			if p % 2 != 0:
				heapq.heappush(l, ((1 - p) // 2, i))
				heapq.heappush(l, ((1 - p) // 2, i + r + 1))
			else:
				heapq.heappush(l, (-(p // 2 - 1), i))
				heapq.heappush(l, (-(p // 2), i + r + 1))
		s += 1
	print(*b)


d = input()

def test(l, r, dict1, list1):
	if r == l:
		if r - l in dict1:
			dict1[r - l].append(l)
		else:
			list1.append(r - l)
			dict1[r - l] = [l]
	elif r > l:
		if r - l not in dict1:
			list1.append(r - l)
			dict1[r - l] = [(r - l) // 2 + l]
		else:
			dict1[r - l].append((r - l) // 2 + l)
		test(l, (r - l) // 2 + l - 1, dict1, list1)
		test((r - l) // 2 + l + 1, r, dict1, list1)
for j in range(int(d)):
	dict1 = {}
	list1 = []
	c = input()
	list2 = [0 for i in range(int(c))]
	test(1, int(c), dict1, list1)
	list1.sort(reverse=True)
	tag = 1
	for i in list1:
		dict1[i].sort()
		for j in dict1[i]:
			list2[j - 1] = tag
			tag += 1
	for i in range(len(list2) - 1):
		print(list2[i], end=' ')
	print(list2[-1])


import heapq as heap
test = int(input())
for testcase in range(test):
	n = int(input())
	arr = [0 for i in range(n)]
	q = []
	moves = 1
	heap.heappush(q, (-1 * n, 0, n - 1))
	while len(q) > 0:
		curr = heap.heappop(q)
		(l, r) = (curr[1], curr[2])
		if l == r:
			arr[l] = moves
			moves += 1
		elif (r - l + 1) % 2 == 1:
			mid = (l + r) // 2
			arr[mid] = moves
			moves += 1
			if mid > l:
				heap.heappush(q, (-1 * (mid - l), l, mid - 1))
			if mid < r:
				heap.heappush(q, (-1 * (r - mid), mid + 1, r))
		else:
			mid = (l + r - 1) // 2
			arr[mid] = moves
			moves += 1
			if mid > l:
				heap.heappush(q, (-1 * (mid - l), l, mid - 1))
			if mid < r:
				heap.heappush(q, (-1 * (r - mid), mid + 1, r))
	print(*arr)


import sys
import heapq
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		h = []
		heapq.heappush(h, (-N, 1, N))
		ans = [0] * N
		for i in range(1, N + 1):
			c = heapq.heappop(h)
			center = -(-(c[2] - 1 + c[1]) // 2)
			ans[center - 1] = i
			if center != c[1]:
				heapq.heappush(h, (-(center - c[1]), c[1], center - 1))
			if center != c[2]:
				heapq.heappush(h, (-(c[2] - center), center + 1, c[2]))
		print(*ans)
main()


import heapq
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	segments = [(-n, 0, n - 1)]
	heapq.heapify(segments)
	counter = 1
	while segments:
		seg = heapq.heappop(segments)
		i = (seg[1] + seg[2]) // 2
		a[i] = counter
		if seg[1] < i:
			heapq.heappush(segments, (seg[1] - i, seg[1], i - 1))
		if seg[2] > i:
			heapq.heappush(segments, (i - seg[2], i + 1, seg[2]))
		counter += 1
	print(*a)


from heapq import heappush, heappop

def helper(n):
	ans = [None for i in range(n)]
	curAction = 1
	heap = [[-n, 0, n - 1]]
	while heap:
		(size, l, r) = heappop(heap)
		mid = l + (r - l) // 2
		ans[mid] = curAction
		curAction += 1
		if mid - 1 >= l:
			heappush(heap, [l - mid, l, mid - 1])
		if mid + 1 <= r:
			heappush(heap, [mid - r, mid + 1, r])
	return ans
for _ in range(int(input())):
	n = int(input())
	print(*helper(n))


a = [(0, 0)] * 200001
b = [0] * 200001

def d(l, r):
	if l > r:
		return
	m = (l + r) // 2
	a[m] = (l - r, m)
	d(l, m - 1)
	d(m + 1, r)
for _ in range(int(input())):
	n = int(input())
	d(1, n)
	c = 1
	for i in sorted(a[1:n + 1]):
		b[i[1]] = c
		c += 1
	print(*b[1:n + 1])


import heapq as hp

def solve():
	for _ in range(int(input())):
		n = int(input())
		pq = [(-n, 0, n - 1)]
		hp.heapify(pq)
		i = 1
		rel = [0] * n
		while len(pq) > 0:
			(length, l, r) = hp.heappop(pq)
			mid = (l + r) // 2
			rel[mid] = i
			i += 1
			if l < mid:
				hp.heappush(pq, (-(mid - l), l, mid - 1))
			if r > mid:
				hp.heappush(pq, (-(r - mid), mid + 1, r))
		for i in rel:
			print(i, end=' ')
		print()
solve()


import heapq
import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	n = int(input())
	ans = [0] * n
	i = 0
	j = n - 1
	h = [(i - j - 1, i, j)]
	heapq.heapify(h)
	ii = 1
	while h:
		(le, x, y) = heapq.heappop(h)
		le = -le
		mid = (x + y) // 2
		ans[mid] = ii
		ii += 1
		if mid - x > 0:
			heapq.heappush(h, (x - mid, x, mid - 1))
		if y - mid > 0:
			heapq.heappush(h, (mid - y, mid + 1, y))
	print(*ans)
	t -= 1


import sys
import heapq
from collections import Counter, deque
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def count(n):
	s = 0
	for i in range(n // 2):
		s += ((n - 2 * (1 + i)) * 4 + 4) * (n // 2 - i)
	return s

def a():
	ans = ''
	for _ in range(int(inp())):
		(n, m) = read()
		if n == 1:
			ans += '0\n'
		elif n == 2:
			ans += str(m) + '\n'
		else:
			ans += str(2 * m) + '\n'
	print(ans)

def b():
	ans = ''
	for _ in range(int(inp())):
		(n, k) = read()
		a = sorted(read())
		b = sorted(read(), reverse=True)
		s = 0
		for i in range(k):
			s += max(a[i], b[i])
		s += sum(a[k:])
		ans += str(s) + '\n'
	print(ans)

def c():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		s = 0
		if n % 2:
			s = count(n)
		else:
			s = count(n - 1)
		if n % 2 == 0:
			s += (2 * n - 1) * (n // 2)
		ans += str(s) + '\n'
	print(ans)

def d():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		arr = [(-n, 1, n)]
		heapq.heapify(arr)
		dic = {}
		num = 1
		while arr and num <= n:
			elem = heapq.heappop(arr)
			(l, a, b) = elem
			ind = (a + b) // 2
			dic[ind] = num
			num += 1
			if a != b:
				heapq.heappush(arr, (-(ind - a + 1), a, ind - 1))
				heapq.heappush(arr, (-(b - ind + 1), ind + 1, b))
		ans += ' '.join(map(str, [dic[i] for i in range(1, n + 1)])) + '\n'
	print(ans)

def e():
	ans = ''
	for _ in range(int(inp())):
		(n, k) = read()
		s = inp().strip()
		dp = []
		x = 0
		for i in s:
			x += int(i)
			dp.append(x)
		min_c = 0
		for i in range(k, n):
			if s[i] == '1' and s[i - k] == '1':
				min_c += dp[i - 1] - dp[i - k]
		ans += str(min_c) + '\n'
	print(ans)
d()


from heapq import *

def solve(n):
	q = [(-n, 0, n - 1)]
	ret = [0] * n
	heapify(q)
	for i in range(1, n + 1):
		(v, l, r) = heappop(q)
		m = (l + r) // 2
		ret[m] = i
		heappush(q, (-(m - l), l, m - 1))
		heappush(q, (-(r - m), m + 1, r))
	print(*ret)
for _ in range(int(input())):
	solve(int(input()))


from heapq import heappush, heapify, heappop
for _ in range(int(input())):
	n = int(input())
	Ans = [0] * (n + 1)
	l = 1
	r = n
	mid = (r + l) // 2
	Heap = [(l - r, l, r)]
	heapify(Heap)
	i = 1
	while len(Heap) > 0:
		t = heappop(Heap)
		l = t[1]
		r = t[2]
		mid = (l + r) // 2
		Ans[mid] = i
		i += 1
		if mid != l:
			heappush(Heap, (l - mid, l, mid - 1))
		if mid != r:
			heappush(Heap, (mid - r, mid + 1, r))
	print(*Ans[1:])


import heapq
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	h = [(-n, (0, n - 1))]
	i = 1
	while i <= n:
		(s, (l, r)) = heapq.heappop(h)
		mid = (l + r) // 2
		a[mid] = i
		heapq.heappush(h, (-(mid - 1 - l), (l, mid - 1)))
		heapq.heappush(h, (-(r - (mid + 1)), (mid + 1, r)))
		i += 1
	print(*a)


from heapq import *
for _ in range(int(input())):
	x = int(input())
	q = [0] * x
	amr = [(x, 0, x - 1)]
	heapify(amr)
	for i in range(1, x + 1):
		x = heappop(amr)
		l = x[1]
		r = x[2]
		mid = (l + r) // 2
		q[mid] = i
		if mid > l:
			heappush(amr, (l - mid, l, mid - 1))
		if mid < r:
			heappush(amr, (mid - r, mid + 1, r))
	print(*q)


import math
t = int(input())
for ti in range(t):
	n = int(input())
	a = [0] * n
	loops = int(math.log(n, 2))
	total = 0
	bounds = [(0, n - 1)]
	singles = []
	for i in range(loops + 1):
		newbounds = []
		for j in range(min(2 ** i, len(bounds))):
			if total == n:
				break
			change = int((bounds[j][0] + bounds[j][1]) / 2)
			a[change] = 2 ** i + j
			total += 1
			if change - 1 - bounds[j][0] > 0:
				newbounds.append((bounds[j][0], change - 1))
			elif change - 1 - bounds[j][0] == 0:
				singles.append((bounds[j][0], change - 1))
			if -change - 1 + bounds[j][1] > 0:
				newbounds.append((change + 1, bounds[j][1]))
			elif -change - 1 + bounds[j][1] == 0:
				singles.append((change + 1, bounds[j][1]))
		newbounds.sort(key=lambda x: (x[1] - x[0], -x[0]), reverse=True)
		bounds = newbounds
	singles.sort(key=lambda x: (x[1] - x[0], -x[0]), reverse=True)
	for (ind, s) in enumerate(singles):
		change = int((s[0] + s[1]) / 2)
		a[change] = n - len(singles) + ind + 1
	print(*a)


import sys
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	n = int(ri())
	ans = [0] * n
	h = [(-n, (0, n - 1))]
	heapq.heapify(h)
	ite = 1
	while len(h) > 0:
		top = heapq.heappop(h)
		(l, r) = top[1]
		length = -1 * top[0]
		if l > r:
			continue
		if l == r:
			ans[l] = ite
		elif length % 2 == 1:
			mid = (l + r) // 2
			ans[mid] = ite
			heapq.heappush(h, (-(length - 1) // 2, (l, mid - 1)))
			heapq.heappush(h, (-(length - 1) // 2, (mid + 1, r)))
		else:
			mid = (l + r - 1) // 2
			ans[mid] = ite
			heapq.heappush(h, (-(length // 2 - 1), (l, mid - 1)))
			heapq.heappush(h, (-length // 2, (mid + 1, r)))
		ite += 1
	print(*ans)


import heapq
T = int(input())
for t in range(T):
	N = int(input())
	A = [0] * N
	H = []
	heapq.heappush(H, (-N, 0))
	for i in range(1, N + 1):
		el = heapq.heappop(H)
		nb_blocks = -el[0]
		ind_first = el[1]
		M = (ind_first + (ind_first + nb_blocks - 1)) // 2
		A[M] = i
		if M > ind_first:
			heapq.heappush(H, (-(M - ind_first), ind_first))
		if M < ind_first + nb_blocks - 1:
			heapq.heappush(H, (-(ind_first + nb_blocks - 1 - M), M + 1))
	print(' '.join(map(str, A)))


import heapq
T = int(input())
for _ in range(T):
	n = int(input())
	res = [0] * n
	ranges = [(-n, 0, n - 1)]
	heapq.heapify(ranges)
	c = 1
	while c <= n:
		(_, l, r) = heapq.heappop(ranges)
		m = r + l >> 1
		res[m] = str(c)
		c += 1
		if l < m:
			heapq.heappush(ranges, (l - m, l, m - 1))
			heapq.heappush(ranges, (m - r, m + 1, r))
		elif m < r:
			heapq.heappush(ranges, (m - r, m + 1, r))
	print(' '.join(res))


import heapq

def solve():
	n = int(input())
	if n == 1:
		print(1)
	else:
		arr = [0 for _ in range(n)]
		q = []
		heapq.heappush(q, (-(n - 1), 0, n - 1))
		for i in range(1, n + 1):
			(_, l, r) = heapq.heappop(q)
			m = (l + r) // 2
			arr[m] = i
			if l < m:
				heapq.heappush(q, (-(m - l - 1), l, m - 1))
			if r > m:
				heapq.heappush(q, (-(r - m - 1), m + 1, r))
		print(*arr)
t = int(input())
for _ in range(t):
	solve()


from heapq import heappush, heappop

def inpint():
	return int(input())

def main():
	t = inpint()
	for _ in range(t):
		n = inpint()
		li = [0] * n
		(l, r) = (1, n)
		Q = [(-n, l)]
		for i in range(1, n + 1):
			d = heappop(Q)
			(l, r) = (d[1], d[1] - d[0] - 1)
			num = (l + r) // 2 if (r - l + 1) % 2 == 1 else (l + r - 1) // 2
			li[num - 1] = i
			(l1, r2) = (l, r)
			(r1, l2) = (num - 1, num + 1)
			heappush(Q, (-r1 + l1 - 1, l1))
			heappush(Q, (-r2 + l2 - 1, l2))
		print(*li)
main()


import heapq
import sys
tcs = int(input())
for tc in range(tcs):
	heap = []
	heapq.heapify(heap)
	n = int(sys.stdin.readline())
	i = 1
	a = [0] * (n + 1)
	heapq.heappush(heap, (-n, 1, n))
	while i <= n:
		(w, l, r) = heapq.heappop(heap)
		if l > r:
			continue
		if l == r:
			a[l] = i
		else:
			a[(l + r) // 2] = i
			if (l + r) % 2 == 0:
				heapq.heappush(heap, ((w + 1) // 2, l, (l + r) // 2 - 1))
				heapq.heappush(heap, ((w + 1) // 2, (l + r) // 2 + 1, r))
			else:
				heapq.heappush(heap, ((w + 2) // 2, l, (l + r) // 2 - 1))
				heapq.heappush(heap, ((w + 1) // 2, (l + r) // 2 + 1, r))
		i += 1
	print(*a[1:])


t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	a = [0 for i in range(n)]
	store = [[]]
	store += [[] for i in range(n)]
	store[n].append((0, n - 1))
	iter_num = 1
	for i in range(n):
		if iter_num == n + 1:
			break
		num_zeros = n - i
		store[num_zeros].sort()
		for (l, r) in store[num_zeros]:
			if (r - l) % 2 == 0:
				center = int((r + l) / 2)
			else:
				center = int((r + l - 1) / 2)
			a[center] = iter_num
			iter_num += 1
			if center - l > 0:
				store[center - l].append((l, center - 1))
			if r - center > 0:
				store[r - center].append((center + 1, r))
	a = [str(i) + ' ' for i in a]
	answers.append(''.join(a))
print(*answers, sep='\n')


from sys import stdin
from math import sqrt
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	d = {n: [(n + 1) // 2]}
	v = [0] * (n + 2)
	stck = [(n + 1) // 2]
	v[(n + 1) // 2] = v[0] = v[-1] = 1
	while stck:
		p = stck.pop()
		l = r = p + 1
		while v[r] == 0:
			r += 1
		r -= 1
		if v[l] == 0:
			m = (l + r) // 2
			stck += (m,)
			v[m] = 1
			if r - l + 1 not in d:
				d[r - l + 1] = [m]
			else:
				d[r - l + 1] += (m,)
		l = r = p - 1
		while v[l] == 0:
			l -= 1
		l += 1
		if v[r] == 0:
			m = (l + r) // 2
			stck += (m,)
			v[m] = 1
			if r - l + 1 not in d:
				d[r - l + 1] = [m]
			else:
				d[r - l + 1] += (m,)
	v = [0] * n
	p = 1
	for i in sorted(d, reverse=True):
		for j in sorted(d[i]):
			v[j - 1] = p
			p += 1
	print(*v)


t = int(input())
for i in range(t):
	n = int(input())
	m = []
	for j in range(n + 1):
		m.append([])
	m[n].append([0, n - 1])
	current = 1
	ans = [0] * n
	for j in range(n):
		m[n - j] = sorted(m[n - j], key=lambda student: student[0])
		for q in m[n - j]:
			if (n - j) % 2 == 0:
				ans[(q[1] + q[0]) // 2] = current
				current += 1
				m[(n - j) // 2].append([(q[1] + q[0]) // 2 + 1, q[1]])
				if n - j > 0:
					m[(n - j) // 2 - 1].append([q[0], (q[1] + q[0]) // 2 - 1])
			else:
				ans[(q[1] + q[0]) // 2] = current
				current += 1
				m[(n - j) // 2].append([q[0], (q[1] + q[0]) // 2 - 1])
				m[(n - j) // 2].append([(q[1] + q[0]) // 2 + 1, q[1]])
	for j in ans:
		print(j)


import heapq

def sol():
	T = int(input())
	for _ in range(T):
		n = int(input())
		A = [0] * n
		max_heap = []
		heapq.heappush(max_heap, (-n, 0, n - 1))
		nth = 1
		while max_heap:
			(_, left, right) = heapq.heappop(max_heap)
			mid = (left + right) // 2
			A[mid] = nth
			nth += 1
			if left == right:
				continue
			if mid - 1 >= left:
				heapq.heappush(max_heap, (-(mid - 1 - left + 1), left, mid - 1))
			if mid + 1 <= right:
				heapq.heappush(max_heap, (-(right - (mid + 1) + 1), mid + 1, right))
		for num in A:
			print(num, end=' ')
		print()
sol()


import sys
input = sys.stdin.buffer.readline
from heapq import *
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	ret = [0] * n
	num = 0
	q = [(-n, (n - 1) // 2)]
	while q:
		(width, cur) = heappop(q)
		width *= -1
		if 0 <= cur <= n - 1 and (not ret[cur]):
			ret[cur] = num + 1
			num += 1
		if width % 2:
			nxt1 = cur - (width + 1) // 2 + (width + 1) // 4
			if 0 <= nxt1 <= n - 1 and (not ret[nxt1]):
				heappush(q, (-((width - 1) // 2), nxt1))
			nxt2 = cur + (width + 1) // 4
			if 0 <= nxt2 <= n - 1 and (not ret[nxt2]):
				heappush(q, (-((width - 1) // 2), nxt2))
		else:
			nxt1 = cur - (width // 2 + 1) // 2
			if 0 <= nxt1 <= n - 1 and (not ret[nxt1]):
				heappush(q, (-((width - 1) // 2), nxt1))
			nxt2 = cur + (width // 2 + 1) // 2
			if 0 <= nxt2 <= n - 1 and (not ret[nxt2]):
				heappush(q, (-(width // 2), nxt2))
	ans.append(' '.join(map(str, ret)))
print('\n'.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	dictionary = {}

	def search_in_depth(l, r):
		if l <= r:
			if l == r:
				if 1 not in dictionary:
					dictionary[1] = [[l]]
				else:
					dictionary[1] += [[l]]
				return
			else:
				if r - l + 1 not in dictionary:
					dictionary[r - l + 1] = [[l, r]]
				else:
					dictionary[r - l + 1] += [[l, r]]
				if (l + r) % 2 == 1:
					search_in_depth(l, (l + r - 1) // 2 - 1)
					search_in_depth((l + r - 1) // 2 + 1, r)
				else:
					search_in_depth(l, (l + r) // 2 - 1)
					search_in_depth((l + r) // 2 + 1, r)
	search_in_depth(1, n)
	sorted_dictionary = {i: dictionary[i] for i in sorted(dictionary, reverse=True)}
	indices = []
	for key in sorted_dictionary:
		for value in sorted_dictionary[key]:
			if (value[0] + value[-1]) % 2 == 1:
				indices += [(value[0] + value[-1] - 1) // 2 - 1]
			else:
				indices += [(value[0] + value[-1]) // 2 - 1]
	answer = [0] * n
	for (counter, ind) in enumerate(indices, 1):
		answer[ind] = counter
	print(*answer)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, functools

def solve(line):
	n = int(line)
	q = []
	heapq.heappush(q, [-(n - 1), 1, n])
	i = 1
	ans = [0] * n
	while q:
		(x, l, r) = heapq.heappop(q)
		nb = None
		if (r - l + 1) % 2 == 1:
			nb = (l + r) // 2
			ans[nb - 1] = i
		else:
			nb = (l + r - 1) // 2
			ans[nb - 1] = i
		if nb - 1 >= l:
			heapq.heappush(q, [-(nb - 1 - l), l, nb - 1])
		if nb + 1 <= r:
			heapq.heappush(q, [-(r - nb - 1), nb + 1, r])
		i += 1
	return ans
T = int(sys.stdin.readline())
t = 0
while True:
	line = sys.stdin.readline().rstrip()
	if not line:
		break
	for i in solve(line):
		print(i, sep=' ', end=' ')
	print()
	t += 1


import sys
from collections import deque
cases = int(sys.stdin.readline())
for _ in range(cases):
	n = int(sys.stdin.readline())
	a = [0] * n
	q = deque()
	q.append((0, n - 1))
	while q:
		(l, r) = q.popleft()
		size = r - l + 1
		if size <= 0:
			continue
		elif size % 2 == 0:
			mid = (l + r - 1) // 2
			a[mid] = size
			q.append((mid + 1, r))
			q.append((l, mid - 1))
		else:
			mid = (l + r) // 2
			a[mid] = size
			q.append((l, mid - 1))
			q.append((mid + 1, r))
	indices = list(range(n))
	indices = sorted(indices, key=lambda i: a[i], reverse=True)
	j = 1
	for i in indices:
		a[i] = j
		j += 1
	print(' '.join(map(str, a)))


def solve():
	srek(0, n - 1)
	ord = argsort(entred)
	ord.reverse()
	ans = [0] * n
	for i in range(n):
		ans[ord[i]] = i + 1
	for a in ans:
		print(a, end=' ')
	print()
	return

def srek(l, r):
	global entred
	ind = (r - l) // 2 + l
	if not entred[ind]:
		entred[ind] = float(r - l) + (n - float(ind)) * 1e-06 + 1
		if ind - 1 >= l:
			srek(l, ind - 1)
		if ind + 1 <= r:
			srek(ind + 1, r)
	return

def argsort(seq):
	return sorted(range(len(seq)), key=seq.__getitem__)
t = int(input())
for i in range(1, t + 1):
	n = int(input())
	entred = [0.0] * n
	solve()


import sys
import heapq as hq
inp = [int(x) for x in sys.stdin.buffer.read().split()]
ii = 0
qqq = inp[ii]
ii += 1
for _ in range(qqq):
	n = inp[ii]
	ii += 1
	a = [[-n, 0]]
	res = [None] * n
	for it in range(n):
		(l, i) = hq.heappop(a)
		l = -l
		res[i + (l - 1) // 2] = it + 1
		if l > 2:
			hq.heappush(a, [-((l - 1) // 2), i])
		if l > 1:
			hq.heappush(a, [-(l // 2), i + (l + 1) // 2])
	print(' '.join((str(x) for x in res)))


from sys import stdin
from heapq import *

class Obj:

	def __init__(self, val):
		self.val = val

	def __lt__(self, other):
		return self.val[1] - self.val[0] > other.val[1] - other.val[0] or (self.val[1] - self.val[0] == other.val[1] - other.val[0] and self.val[0] < other.val[0])

	def __str__(self):
		return str(self.val)
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = [0] * n
	x = [Obj((0, n))]
	heapify(x)
	cou = 1
	while len(x):
		y = heappop(x).val
		k = (y[0] + y[1] - 1) // 2
		arr[k] = str(cou)
		cou += 1
		if k > y[0]:
			heappush(x, Obj((y[0], k)))
		if y[1] > k + 1:
			heappush(x, Obj((k + 1, y[1])))
	print(' '.join(arr))


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	lst = list()
	arr = [0] * n
	idx = 1
	heapq.heappush(lst, (-n, 0, n - 1))
	while lst:
		(_, left, right) = heapq.heappop(lst)
		mid = (left + right) // 2
		arr[mid] = idx
		idx += 1
		if mid != left:
			heapq.heappush(lst, (-1 * (mid - left), left, mid - 1))
		if right != mid:
			heapq.heappush(lst, (-1 * (right - mid), mid + 1, right))
	print(*arr)


from heapq import *
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		n = II()
		hp = []
		ans = [-1] * n
		heappush(hp, (-n + 1, 0, n - 1))
		c = 1
		while hp:
			(d, l, r) = heappop(hp)
			i = (l + r) // 2
			ans[i] = c
			c += 1
			if l <= i - 1:
				heappush(hp, (l - i + 1, l, i - 1))
			if i + 1 <= r:
				heappush(hp, (i + 1 - r, i + 1, r))
		print(*ans)
main()


import itertools
import heapq

def maxheappush(heap, length, left, right):
	heapq.heappush(heap, (-length, left, right))

def maxheappop(heap):
	(length, left, right) = heapq.heappop(heap)
	return (-length, left, right)

def get_length(left, right):
	return right - left + 1

def build_array(n):
	counter = itertools.count(1)
	answer = [0] * n
	heap = []
	maxheappush(heap, n, 1, n)
	while heap:
		(length, left, right) = maxheappop(heap)
		middle = left + (right - left) // 2
		answer[middle - 1] = next(counter)
		if left == right:
			continue
		if left < middle:
			length = get_length(left=left, right=middle - 1)
			maxheappush(heap, length, left, middle - 1)
		if middle < right:
			length = get_length(left=middle + 1, right=right)
			maxheappush(heap, length, middle + 1, right)
	return answer

def main():
	for _ in range(int(input().strip())):
		n = int(input().strip())
		print(' '.join(map(str, build_array(n))))
main()


for i in range(int(input())):
	n = int(input())
	if n == 1:
		print(1)
		continue
	step = 1
	result = [0 for j in range(n + 1)]
	recorder = {n: [[1, n]]}
	max_value = n
	while max_value > 0:
		recorder[max_value].sort(key=lambda a: a[0])
		while recorder[max_value]:
			temp = recorder[max_value].pop(0)
			result[(temp[0] + temp[1]) // 2] = step
			step += 1
			left_node = [temp[0], (temp[0] + temp[1]) // 2 - 1]
			right_node = [(temp[0] + temp[1]) // 2 + 1, temp[1]]
			if left_node[0] <= left_node[1]:
				try:
					recorder[left_node[1] - left_node[0]].append(left_node)
				except:
					recorder[left_node[1] - left_node[0]] = [left_node]
			if right_node[0] <= right_node[1]:
				try:
					recorder[right_node[1] - right_node[0]].append(right_node)
				except:
					recorder[right_node[1] - right_node[0]] = [right_node]
		recorder.pop(max_value)
		max_value = max(recorder.keys())
	for j in range(1, n + 1):
		if result[j] == 0:
			result[j] = step
			step += 1
	print(' '.join(map(str, result[1:])))


from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	ans = [0] * n
	groups = [(0, 0, n)]
	i = 1
	while groups:
		(_, l, r) = heappop(groups)
		mid = (l + r - 1) // 2
		ans[mid] = i
		i += 1
		if l < mid:
			heappush(groups, (l - mid, l, mid))
		if mid + 1 < r:
			heappush(groups, (mid + 1 - r, mid + 1, r))
	print(*ans)


import heapq as hq
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	q = []
	hq.heapify(q)
	hq.heappush(q, (-n, 0, n - 1))
	e = 0
	while q != []:
		e += 1
		(d, i, j) = hq.heappop(q)
		m = (i + j) // 2
		a[m] = e
		if i <= m - 1:
			k = m - 1
			diff = k - i + 1
			hq.heappush(q, (-diff, i, k))
		if j >= m + 1:
			k = m + 1
			diff = j - k + 1
			hq.heappush(q, (-diff, k, j))
	print(*a)


import heapq

def solve(n):
	ans = [-1 for _ in range(n)]
	res = []
	heapq.heappush(res, (-n, 0, n - 1))
	for i in range(n):
		(neg_l, left, right) = heapq.heappop(res)
		mid = (right + left) // 2
		ans[mid] = i + 1
		if mid != left:
			heapq.heappush(res, (-(mid - 1 - left + 1), left, mid - 1))
		if mid != right:
			heapq.heappush(res, (-(right - mid), mid + 1, right))
	return [str(n) for n in ans]
t = int(input())
for i in range(t):
	n = int(input())
	print(' '.join(solve(n)))


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	heap = [(-n, 0)]
	action = 1
	while heap:
		(length, left) = heapq.heappop(heap)
		length = -length
		right = left + length - 1
		mid = (left + right) // 2
		a[mid] = action
		if mid > left:
			heapq.heappush(heap, (-1 * (mid - left), left))
		if mid < right:
			heapq.heappush(heap, (-1 * (right - mid), mid + 1))
		action += 1
	for i in range(n):
		if i > 0:
			print(' ')
		print(a[i])


t = int(input())
for tt in range(t):
	n = int(input())
	a = [0] * n
	a.append(-1)
	p = 1
	while p <= n:
		size = 0
		i = -1
		j = -1
		bhul = False
		while True:
			i = j
			while a[i]:
				i += 1
				if i == n + 1:
					bhul = True
					break
			if bhul:
				break
			j = i
			while a[j] == 0:
				j += 1
			size = max(size, j - i)
		i = -1
		j = -1
		bhul = False
		while True:
			i = j
			while a[i]:
				i += 1
				if i == n + 1:
					bhul = True
					break
			if bhul:
				break
			j = i
			while a[j] == 0:
				j += 1
			if j - i == size:
				if size % 2 == 1:
					a[int((i + j) / 2)] = p
					p += 1
				else:
					a[round((i + j) / 2) - 1] = p
					p += 1
	a.pop()
	for x in a:
		print(x, end=' ')
	print()


import heapq
for _ in range(int(input())):
	n = int(input())
	I = iter(range(1, n + 1))
	result = [0] * n
	heap = [(-n, 1, n)]
	while heap:
		(_, left, right) = heapq.heappop(heap)
		mid = left + (right - left) // 2
		result[mid - 1] = str(next(I))
		if left < mid:
			heapq.heappush(heap, (left - mid, left, mid - 1))
		if mid < right:
			heapq.heappush(heap, (mid - right, mid + 1, right))
	print(' '.join(result))


import math
from sys import stdin, stdout
from heapq import heapify, heappop, heappush
from collections import Counter
T = int(stdin.readline())
for i in range(T):
	N = int(stdin.readline())
	arr = [0] * N
	q = [(1 - N, 1, N)]
	mv = 1
	while q:
		(d, l, r) = heappop(q)
		m = l + (r - l) // 2
		arr[m - 1] = mv
		mv += 1
		if m + 1 <= r:
			heappush(q, (m - r, m + 1, r))
		if l <= m - 1:
			heappush(q, (l - m, l, m - 1))
	for a in arr:
		print(a, end=' ')
	print()


import sys
from heapq import heappush, heappop

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	que = [(-N, 0)]
	ans = [0] * N
	for i in range(N):
		(ln, l) = heappop(que)
		ln = -ln
		r = l + ln
		m = ceil(l + r, 2) - 1
		ans[m] = i + 1
		heappush(que, (-(m - l), l))
		heappush(que, (-(r - (m + 1)), m + 1))
	print(*ans)


import heapq
for _ in [0] * int(input()):
	n = int(input())
	q = []
	heapq.heappush(q, (-n, 0, n - 1))
	a = [0] * n
	i = 1
	while len(q):
		(x, l, r) = heapq.heappop(q)
		m = l + r >> 1
		a[m] = i
		i += 1
		if l != m:
			heapq.heappush(q, (l - m, l, m - 1))
		if r != m:
			heapq.heappush(q, (m - r, m + 1, r))
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	res = [0] * (n + 1)
	dp = [[] for _ in range(n + 1)]
	dp[n] = [1]
	count = 1
	for i in range(n, 0, -1):
		if len(dp[i]) > 0:
			s_dp = sorted(dp[i])
			for k in s_dp:
				if (i - 1) // 2 > 0:
					dp[(i - 1) // 2].append(k)
				res[k + (i - 1) // 2] = count
				count += 1
				dp[i // 2].append(k + (i + 1) // 2)
	print(' '.join(list(map(str, res[1:]))))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	for _ in range(N()):
		n = N()
		(l, r) = (1, n)
		res = [0] * (n + 1)
		q = [(-n, l, r)]
		tag = 1
		while q:
			(ll, nl, nr) = heappop(q)
			if (nr - nl + 1) % 2 == 1:
				index = (nl + nr) // 2
				res[index] = tag
				if index - 1 >= nl:
					heappush(q, (-(index - 1 - nl + 1), nl, index - 1))
				if index + 1 <= nr:
					heappush(q, (-(nr - index), index + 1, nr))
			else:
				index = (nl + nr - 1) // 2
				res[index] = tag
				if index - 1 >= nl:
					heappush(q, (-(index - 1 - nl + 1), nl, index - 1))
				if index + 1 <= nr:
					heappush(q, (-(nr - index), index + 1, nr))
			tag += 1
		print(*res[1:])
main()


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	zerosub = [(-n, 0)]
	heapq.heapify(zerosub)
	i = 1
	while zerosub:
		(length, start) = heapq.heappop(zerosub)
		length *= -1
		l = start
		r = length + l - 1
		if length % 2 == 0:
			mid = (l + r - 1) // 2
			a[mid] = i
		else:
			mid = (l + r) // 2
			a[mid] = i
		if mid - l:
			heapq.heappush(zerosub, (-(mid - l), l))
		if r - mid:
			heapq.heappush(zerosub, (-(r - mid), mid + 1))
		i += 1
	print(*a)


from heapq import heapify, heappush, heappop
for _ in range(int(input())):
	n = int(input())
	l = [0] * n
	q = [(-n, 0, n - 1)]
	heapify(q)
	v = 1
	while q:
		(d, a, b) = heappop(q)
		d *= -1
		m = (a + b) // 2
		l[m] = v
		if m - 1 >= 0 and a <= m - 1:
			d = m - a
			heappush(q, (-d, a, m - 1))
		if m + 1 < n and b >= m + 1:
			d = b - m
			heappush(q, (-d, m + 1, b))
		v += 1
	print(*l)


from sys import stdin, stdout
from pprint import pprint
from heapq import heappush, heappop
for _ in range(int(stdin.readline())):
	n = int(input())
	ans = [-1] * (n + 1)
	cnt = 1
	heap = [(-(n - 1 + 1), 1, n)]
	while cnt <= n:
		node = heappop(heap)
		l = node[1]
		r = node[2]
		if r >= l:
			pos = l + (r - l) // 2
			ans[pos] = cnt
			cnt += 1
			heappush(heap, (-(pos - 1 - l + 1), l, pos - 1))
			heappush(heap, (-(r - (pos + 1) + 1), pos + 1, r))
	for i in ans[1:]:
		stdout.write(str(i) + ' ')
	stdout.write('\n')


import heapq as heap

def solve():
	n = int(input())
	final = [0] * (n + 1)
	li = []
	heap.heapify(li)
	heap.heappush(li, (n, 1, n))
	count = 1
	while count <= n:
		(ll, l, r) = heap.heappop(li)
		mid = (l + r) // 2
		final[mid] = count
		count += 1
		if mid - l > 0:
			heap.heappush(li, (-(mid - l), l, mid - 1))
		if r - mid > 0:
			heap.heappush(li, (-(r - mid), mid + 1, r))
	print(*final[1:])
t = int(input())
for i in range(t):
	solve()


from sys import stdin, stdout
import math
import heapq
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		n = I()
		arr = [0 for i in range(n)]
		q = []
		heapq.heappush(q, (-n, 0, n - 1))
		i = 1
		while len(q):
			(x, l, r) = heapq.heappop(q)
			m = (l + r) // 2
			arr[m] = i
			if l != m:
				heapq.heappush(q, (l - m, l, m - 1))
			if r != m:
				heapq.heappush(q, (m - r, m + 1, r))
			i += 1
		print(*arr)
main()


import heapq as hq
t = int(input())
for _ in range(t):
	n = int(input())
	ans = list(bytearray(n))
	curr = 0
	heap = []
	hq.heappush(heap, (-n, (0, n - 1)))
	while heap:
		(val, segment) = hq.heappop(heap)
		mid = (segment[0] + segment[1]) // 2
		ans[mid] = curr + 1
		curr += 1
		if segment[0] <= mid - 1:
			val = segment[0] - mid
			hq.heappush(heap, (val, (segment[0], mid - 1)))
		if mid + 1 <= segment[1]:
			val = mid - segment[1]
			hq.heappush(heap, (val, (mid + 1, segment[1])))
	print(*ans)


import sys
input = sys.stdin.readline
import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	ans = [0] * n
	queue = [[-n, 0, n - 1]]
	i = 1
	while queue:
		(s, l, r) = heapq.heappop(queue)
		mid = (l + r) // 2
		if ans[mid] != 0:
			continue
		ans[mid] = i
		i += 1
		if l <= mid - 1:
			heapq.heappush(queue, [-(mid - l), l, mid - 1])
		if mid + 1 <= r:
			heapq.heappush(queue, [-(r - mid), mid + 1, r])
	print(*ans)


def binsrh(l, h):
	if l > h:
		return
	c = (l + h) // 2
	myh.append((h - l + 1, -c))
	if l == h:
		return
	if (h - l + 1) % 2 == 0:
		binsrh(c + 1, h)
		binsrh(l, c - 1)
	else:
		binsrh(l, c - 1)
		binsrh(c + 1, h)
cases = int(input())
for t in range(cases):
	n = int(input())
	a = [0] * n
	myh = []
	binsrh(0, n - 1)
	myh = sorted(sorted(myh, key=lambda x: x[1], reverse=True), reverse=True)
	c = 1
	for (i, j) in myh:
		a[-j] = c
		c += 1
	print(*a)


import heapq
for ii in range(int(input())):
	n = int(input())
	ans = [0] * (n + 1)
	rang = [(n, 1, n)]
	i = 1
	heapq.heapify(rang)
	while rang:
		(length, s, e) = heapq.heappop(rang)
		ind = (s + e) // 2
		ans[ind] = i
		i += 1
		if s <= ind - 1:
			heapq.heappush(rang, (abs(ind - s) * -1, s, ind - 1))
		if ind + 1 <= e:
			heapq.heappush(rang, (abs(ind - e) * -1, ind + 1, e))
	print(*ans[1:])


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():

	def add_to_arr(L, R):
		length = R - L + 1
		middle = (L + R) // 2
		arr.append((-length, middle))
		if L < middle:
			add_to_arr(L, middle - 1)
		if R > middle:
			add_to_arr(middle + 1, R)
		return
	N = getInt()
	A = [0] * N
	arr = []
	add_to_arr(0, N - 1)
	arr.sort()
	for i in range(1, N + 1):
		A[arr[i - 1][1]] = i
	print(*A)
	return
T = getInt()
for t in range(T):
	solve()


for j in range(int(input())):
	h = 1
	n = int(input())
	A = []
	for i in range(n):
		A.append(0)
	B = [[0, n - 1]]
	while len(B) > 0:
		for b in B:
			A[(b[0] + b[1]) // 2] = h
			h += 1
		B = []
		if A[-1] == 0:
			x = 0
			for i in range(1, len(A)):
				if A[i] != 0 and A[i - 1] == 0:
					B.append([x, i - 1])
				elif A[i] == 0 and A[i - 1] != 0:
					x = int(i)
				elif A[i] != 0:
					x = int(i)
			B.append([x, i])
		m = -1
		for b in B:
			if b[1] - b[0] > m:
				m = b[1] - b[0]
		B2 = []
		for b in B:
			if b[1] - b[0] == m:
				B2.append(b)
		B = list(B2)
	print(*A)


from sys import stdin
import heapq
for case in range(int(stdin.readline())):
	n = int(stdin.readline())
	out = [0 for x in range(n)]
	seq = [(-n, 0, n - 1)]
	count = 0
	while seq:
		count += 1
		(size, l, r) = heapq.heappop(seq)
		out[(l + r) // 2] = count
		if r > l + 1:
			heapq.heappush(seq, (-((l + r) // 2 - l), l, (l + r) // 2 - 1))
		if r > l:
			heapq.heappush(seq, (-(r - (l + r) // 2), (l + r) // 2 + 1, r))
	print(' '.join([str(x) for x in out]))


import heapq
T = int(input())
for t in range(T):
	n = int(input())
	a = [0 for i in range(n)]
	interval_length = n
	prev_pos = [(-n, 0, n - 1)]
	heapq.heapify(prev_pos)
	nb = 1
	while True:
		try:
			(interval_length, l, r) = heapq.heappop(prev_pos)
		except Exception:
			break
		interval_length = -interval_length
		if l == r:
			a[l] = nb
			nb += 1
		else:
			middle = (l + r) // 2
			a[middle] = nb
			nb += 1
			interval_length = interval_length // 2
			if middle - 1 >= l:
				new_l = middle - l
				heapq.heappush(prev_pos, (-new_l, l, middle - 1))
			if middle + 1 <= r:
				new_l = r - middle
				heapq.heappush(prev_pos, (-new_l, middle + 1, r))
	print(' '.join(map(str, a)))


from collections import defaultdict
import os
import sys
from io import BytesIO, IOBase

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
ii = lambda : int(input())
lmii = lambda : list(map(int, input().split()))
slmii = lambda : sorted(map(int, input().split()))
li = lambda : list(input())
mii = lambda : map(int, input().split())
msi = lambda : map(str, input().split())

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def main():
	for _ in ' ' * int(input()):
		n = ii()
		a = [0] * n
		cnt = 1
		ind = []
		dd = defaultdict(SortedList)
		for i in range(n):
			ind.append(i)
		dd[n].add(ind)
		lnc = SortedList([n])
		while cnt <= n:
			curr = lnc[-1]
			lst = dd[lnc[-1]][0]
			dd[lnc[-1]].pop(0)
			ln = len(lst)
			f = (ln - 1) // 2
			s = curr - (ln - 1) // 2 - 1
			val = (ln - 1) // 2 + 1
			lnc.add(f)
			lnc.add(s)
			lnc.pop()
			p = lst[f]
			a[p] = cnt
			if len(lst[:f]):
				dd[f].add(lst[:f])
			if len(lst[val:]):
				dd[s].add(lst[val:])
			cnt += 1
		print(*a)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import heapq

def cal(n):
	ans = [0] * n
	arr = [(-n, 0)]
	heapq.heapify(arr)
	for i in range(n):
		(size, start) = heapq.heappop(arr)
		size = -size
		h = (size - 1) // 2
		ans[start + h] = i + 1
		if h > 0:
			heapq.heappush(arr, (-h, start))
		if size - h - 1 > 0:
			heapq.heappush(arr, (-size + h + 1, start + h + 1))
	return ans

def web():
	T = int(input())
	for t in range(1, T + 1):
		arr = [int(s) for s in input().split(' ')]
		ans = cal(arr[0])
		for a in ans:
			print(a, end=' ')
		print()

def file():
	x = open('p4_in.txt')
	T = int(x.readline())
	for t in range(1, T + 1):
		arr = [int(s) for s in x.readline().split(' ')]
		ans = cal(arr[0])
		for a in ans:
			print(a, end=' ')
		print()
web()


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq as hq
t = int(input())

def solve():
	n = int(input())
	a = [(-n, 0, n - 1)]
	count = 1
	ans = [0] * n
	while len(a) and count < n + 1:
		(size, l, r) = hq.heappop(a)
		if l > r:
			continue
		if l == r:
			ans[l] = count
			count += 1
		elif (r - l + 1) % 2 == 1:
			mid = (l + r) // 2
			ans[mid] = count
			count += 1
			hq.heappush(a, (-1 * (mid - l), l, mid - 1))
			hq.heappush(a, (-1 * (r - mid), mid + 1, r))
		else:
			mid = (l + r - 1) // 2
			ans[mid] = count
			count += 1
			hq.heappush(a, (-1 * (mid - l), l, mid - 1))
			hq.heappush(a, (-1 * (r - mid), mid + 1, r))
	print(*ans)
while t:
	solve()
	t -= 1


import heapq

def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))
a = [0] * 500000

def solve():
	n = read_int()
	Q = [(-n, 0, n - 1)]
	i = 1
	while len(Q) != 0:
		(length, l, r) = heapq.heappop(Q)
		mid = (l + r) // 2
		a[mid] = i
		if mid - l > 0:
			heapq.heappush(Q, (l - mid, l, mid - 1))
		if r - mid > 0:
			heapq.heappush(Q, (mid - r, mid + 1, r))
		i += 1
	return ' '.join(map(str, a[:n]))
T = read_int()
for _ in range(T):
	print(solve())


import sys

def answer(n):
	ans = [0 for _ in range(n)]
	stack = [(0, n - 1)]
	buckets = [[] for _ in range(n + 1)]
	bucket_set = set()
	for i in range(n):
		tup = stack.pop()
		l = tup[0]
		r = tup[1]
		mid = (l + r) // 2
		w = r - l + 1
		buckets[w].append(mid)
		bucket_set.add(w)
		if mid - 1 >= l:
			stack.append((l, mid - 1))
		if r >= mid + 1:
			stack.append((mid + 1, r))
	ctr = 1
	bucket_list = sorted(bucket_set, reverse=True)
	for b in bucket_list:
		buckets[b].sort()
		for midpoint in buckets[b]:
			ans[midpoint] = ctr
			ctr += 1
	return ans

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		print(*answer(n))
		t -= 1
	return
main()


def action(n):

	def order(l, r, index):
		if l == r:
			index.append((1, abs(l)))
			return
		if (l - r + 1) % 2 == 1:
			mid = (l + r) // 2
		else:
			mid = (l + r - 1) // 2
		index.append((r - l + 1, abs(mid)))
		if l < mid:
			order(l, mid - 1, index)
		if mid < r:
			order(mid + 1, r, index)
	index = []
	order(-n, -1, index)
	index = sorted(index, reverse=True)
	count = 1
	arr = [0] * n
	for (length, key) in index:
		arr[-key] = count
		count += 1
	return arr
t = int(input())
for i in range(t):
	n = int(input())
	arr = action(n)
	for k in arr:
		print(k, end=' ')
	print('')


li = []

def add_element(left, right):
	if right - left == 0:
		return
	if right - left == 1:
		li.append([-1, left])
		return
	mid = (left + right) // 2
	if (right - left) % 2 == 0:
		mid = mid - 1
	li.append([-(right - left), mid])
	add_element(left, mid)
	add_element(mid + 1, right)
T = int(input())
for tc in range(T):
	n = int(input())
	arr = [0] * n
	li = []
	add_element(0, n)
	li.sort()
	val = 1
	for i in range(n):
		arr[li[i][1]] = val
		val += 1
	print(*arr)


import heapq
test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	queue = [(-n, 0)]
	a = ['0' for _ in range(n)]
	i = 1
	while len(queue) > 0:
		(currentLen, l) = heapq.heappop(queue)
		currentLen = -currentLen
		r = l + currentLen - 1
		middle = (l + r) // 2
		a[middle] = str(i)
		i += 1
		if middle - l > 0:
			heapq.heappush(queue, (-(middle - l), l))
		if r - middle > 0:
			heapq.heappush(queue, (-(r - middle), middle + 1))
	print(' '.join(a))


from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	ranges = [(n, 0, n - 1)]
	step = 1
	while len(ranges) > 0:
		(_, l, r) = heappop(ranges)
		mid = (r - l) // 2 + l
		a[mid] = str(step)
		step += 1
		if mid != l:
			heappush(ranges, (n - mid + l, l, mid - 1))
		if mid != r:
			heappush(ranges, (n - r + mid, mid + 1, r))
	print(' '.join(a))


import heapq
for _ in range(int(input())):
	n = int(input())
	arr = [0] * n
	a = []
	heapq.heapify(a)
	heapq.heappush(a, (-n, 0, n - 1))
	for i in range(1, n + 1):
		temp = heapq.heappop(a)
		mid = (temp[1] + temp[2]) // 2
		arr[mid] = i
		l = mid - temp[1]
		r = temp[2] - mid
		heapq.heappush(a, (-l, temp[1], mid - 1))
		heapq.heappush(a, (-r, mid + 1, temp[2]))
	print(*arr)


from heapq import heappush, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	hp = [[-n, 1, n]]
	ans = [0] * (n + 1)
	for i in range(1, n + 1):
		(num, l, r) = heappop(hp)
		m = (l + r) // 2
		ans[m] = i
		if l <= m - 1:
			heappush(hp, [-(m - l), l, m - 1])
		if m + 1 <= r:
			heappush(hp, [-(r - m), m + 1, r])
	print(*ans[1:])


for f in range(int(input())):
	n = int(input())
	segs = [[n, 0]]
	sol = [0] * n
	i = 0
	prev = n
	j = 0
	while i < n:
		i += 1
		if j < 0:
			segs.sort(reverse=True)
			j = 0
			while j < len(segs) and segs[j][0] == segs[j + 1][0]:
				j += 1
			prev = segs[0][0]
		m = segs[j][1] + (segs[j][0] - 1) // 2
		sol[m] = i
		segs.append([segs[j][0] // 2, m + 1])
		segs.append([(segs[j][0] - 1) // 2, segs[j][1]])
		segs[j][0] = 0
		j -= 1
	print(*sol)


from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	h = [(-n, 0, n - 1)]
	a = [0] * n
	i = 1
	while len(h) != 0:
		(_, L, R) = heappop(h)
		mid = (L + R) // 2
		a[mid] = i
		i += 1
		if L < mid:
			heappush(h, (L - mid, L, mid - 1))
		if mid < R:
			heappush(h, (mid - R, mid + 1, R))
	print(*a)


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	queue = [(1 - n, 1, n)]
	heapq.heapify(queue)
	out = [0] * (n + 1)
	number = 1
	while queue:
		task = heapq.heappop(queue)
		mid = (task[1] + task[2]) // 2
		if mid != task[1]:
			heapq.heappush(queue, (task[1] - mid + 1, task[1], mid - 1))
		if mid != task[2]:
			heapq.heappush(queue, (mid + 1 - task[2], mid + 1, task[2]))
		out[mid] = number
		number += 1
	for i in range(1, n + 1):
		print(out[i], end=' ')
	print()


from heapq import *
for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	pq = [(-n + 1, 0, n - 1)]
	count = 1
	for i in range(n):
		(size, l, r) = heappop(pq)
		m = l + (r - l) // 2
		ans[m] = count
		count += 1
		if m + 1 <= r:
			heappush(pq, (m + 1 - r, m + 1, r))
		if l <= m - 1:
			heappush(pq, (l - (m - 1), l, m - 1))
	print(*ans)


import heapq as hq

def answer(n):
	q = []
	hq.heappush(q, (-n, 0, n - 1))
	A = [0] * n
	i = 1
	while len(q) > 0:
		(l, s, e) = hq.heappop(q)
		x = (s + e) // 2
		A[x] = i
		i += 1
		if x > s:
			hq.heappush(q, (-(x - s), s, x - 1))
		if x < e:
			hq.heappush(q, (-(e - x), x + 1, e))
	print(*A)
t = int(input())
for i in range(t):
	n = int(input())
	answer(n)


import atexit
import io
import sys
from collections import deque
from heapq import *
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__

def pur(a, b):
	if (b - a + 1) % 2 == 1:
		m = (b + a) // 2
	else:
		m = (b + a - 1) // 2
	return m
tc = int(input())
for zzz in range(tc):
	n = int(input())
	arr = []
	arr.append(0)
	for i in range(n):
		arr.append(0)
	dq1 = deque()
	dq2 = []
	dq1.append((1, n))
	while len(dq1) > 0:
		tem = dq1.popleft()
		a = tem[0]
		b = tem[1]
		m = pur(a, b)
		dq2.append((-(tem[1] - tem[0]), m))
		if a != b:
			if a != m:
				dq1.append((a, m - 1))
			if b != m:
				dq1.append((m + 1, b))
	heapify(dq2)
	i = 1
	while len(dq2) > 0:
		r = heappop(dq2)
		d = r[1]
		arr[d] = i
		i += 1
	for i in range(1, n + 1):
		print(arr[i], end=' ')
	print()


t = int(input())

def mycmp(val1, val2):
	if val1[0] != val2[0]:
		return val1[0] > val2[0]
	else:
		return val1[1] < val2[1]

def fun(l, r):
	if l > r:
		return
	mid = int((r + l) / 2)
	ans[mid] = int(r - l + 1)
	fun(l, mid - 1)
	fun(mid + 1, r)
for i in range(t):
	n = int(input())
	ans = [0] * (n + 1)
	fun(1, n)
	a = []
	for i in range(1, n + 1):
		a.append([ans[i], n - i])
	a.sort()
	a.reverse()
	for i in range(n):
		ans[n - a[i][1]] = i + 1
	for i in range(1, n + 1):
		print(ans[i], end=' ')
	print('')


import heapq
import math
from heapq import heappush
from heapq import heappop
n = int(input())
for i in range(n):
	m = int(input())
	h = []
	arr = [0 for x in range(m)]
	heappush(h, (-m, 0))
	for j in range(m):
		el = heappop(h)
		l = el[0] * -1
		l = math.ceil(l)
		l1 = math.floor((l - 0.001) / 2)
		l2 = el[1]
		pos = l1 + l2
		arr[pos] = j + 1
		a = -(l1 - l2 / 1000000000.0)
		b = l2
		if a < -0.5:
			heappush(h, (a, b))
		a = -(l - l1 - 1 - (l2 + 1 + l1) / 1000000000.0)
		b = l2 + 1 + l1
		if a < -0.5:
			heappush(h, (a, b))
	arr = [str(x) for x in arr]
	print(' '.join(arr))


import heapq
t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = [0] * n
	l = 0
	r = n - 1
	mid = int((l + r) / 2)
	a[mid] = 1
	li = []
	heapq.heapify(li)
	if mid - l > 0:
		heapq.heappush(li, (-1 * (mid - l), l, mid - 1))
	if r - mid > 0:
		heapq.heappush(li, (-1 * (r - mid), mid + 1, r))
	for i in range(2, n + 1):
		(lent, l, r) = heapq.heappop(li)
		mid = int((l + r) / 2)
		a[mid] = i
		if mid - l > 0:
			heapq.heappush(li, (-1 * (mid - l), l, mid - 1))
		if r - mid > 0:
			heapq.heappush(li, (-1 * (r - mid), mid + 1, r))
	for i in a:
		print(i, end=' ')
	print()


from heapq import heapify, heappush, heappop

def main():
	n = int(input())
	ans = [0 for i in range(n)]
	q = []
	heapify(q)
	heappush(q, (-n, 0, n - 1))
	for i in range(1, n + 1):
		curr = heappop(q)
		index = (curr[1] + curr[2]) // 2
		ans[index] = i
		p1 = index - curr[1]
		p2 = curr[2] - index
		heappush(q, (-p1, curr[1], index - 1))
		heappush(q, (-p2, index + 1, curr[2]))
	print(*ans)
t = int(input())
for _ in range(t):
	main()


import heapq

def solve():
	n = int(input())
	final = [0] * (n + 1)
	li = []
	heapq.heapify(li)
	heapq.heappush(li, (n, 1, n))
	count = 1
	while count <= n:
		(ll, node_left, node_right) = heapq.heappop(li)
		final[(node_left + node_right) // 2] = count
		count += 1
		if (node_left + node_right) // 2 - node_left > 0:
			heapq.heappush(li, (-((node_left + node_right) // 2 - node_left), node_left, (node_left + node_right) // 2 - 1))
		if node_right - (node_left + node_right) // 2 > 0:
			heapq.heappush(li, (-(node_right - (node_left + node_right) // 2), (node_left + node_right) // 2 + 1, node_right))
	print(*final[1:])
t = int(input())
for i in range(t):
	solve()


from collections import deque
import heapq

def construct(nums, q):
	arr = []
	num = 1
	while q:
		(left, right) = q.popleft()
		if left <= right:
			if (left + right + 1) % 2 == 0:
				mid = (left + right - 1) // 2
				q.append([mid + 1, right])
				q.append([left, mid - 1])
			else:
				mid = (left + right) // 2
				q.append([left, mid - 1])
				q.append([mid + 1, right])
			arr.append([right - left, left, right, mid])
	sorted_arr = sorted(arr, key=lambda x: (-x[0], x[1], x[2]))
	num = 1
	for i in range(len(sorted_arr)):
		(zeroes, left, right, mid) = sorted_arr[i]
		nums[mid] = num
		num += 1
t = int(input())
while t:
	t -= 1
	n = int(input())
	nums = [0 for i in range(n)]
	q = deque()
	q.append([0, n - 1])
	arr = []
	construct(nums, q)
	for i in range(len(nums)):
		print(nums[i], end=' ')
	print()


from sys import stdin, stdout
from collections import deque
from heapq import heappush, heappop
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x * (x + 1) // 2
I = lambda x: 1 + 2 * x
R = lambda : stdin.readline()
Ri = lambda x: map(int, x.split())
Rs = lambda x: map(str, x.split())
Rf = lambda x: map(float, x.split())
MaxN = int(100000.0) + 5

def f(L, R, A):
	B = []
	heappush(B, (0, L, R))
	cont = 0
	while len(B):
		x = heappop(B)
		(L, R) = (x[1], x[2])
		cont += 1
		pos = (R + L) // 2
		A[pos] = cont
		if L < pos:
			heappush(B, (-pos + L, L, pos - 1))
		if pos < R:
			heappush(B, (-R + pos, pos + 1, R))

def main():
	A = [0] * (2 * MaxN)
	T = int(R())
	for casos in range(T):
		n = int(R())
		f(1, n, A)
		for i in range(1, n + 1):
			Ps(str(A[i]) + ' ')
		Ps('\n')
main()


from sys import stdin
from collections import Counter, deque
from heapq import heappush, heappop
from itertools import product
T = int(input())
for _ in range(T):
	n = int(input())
	(h, a, op) = ([], [0] * n, 1)
	heappush(h, (-n, 0, n - 1))
	while h:
		(sz, l, r) = heappop(h)
		p = (l + r) // 2
		a[p] = op
		op += 1
		(lsz, rsz) = (p - l, r - p)
		if lsz > 0:
			heappush(h, (-lsz, l, p - 1))
		if rsz > 0:
			heappush(h, (-rsz, p + 1, r))
	print(*a)


class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: gcd(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	(start, end) = (0, n - 1)
	length = end - start
	queue = [(length, start, end)]
	cur = 1
	while cur <= n:
		(length, start, end) = heapq.heappop(queue)
		mid = (start + end) // 2
		a[mid] = cur
		cur += 1
		heapq.heappush(queue, (-1 * (mid - 1 - start), start, mid - 1))
		heapq.heappush(queue, (-1 * (end - (mid + 1)), mid + 1, end))
	print(' '.join((str(k) for k in a)))


from sys import stdout, stdin
(_input, _print) = (stdin.buffer.readline, stdout.write)
(_int, _range, _len) = (int, range, len)

def heap_push(h, v):
	i = _len(h)
	h.append(v)
	while i - 1 // 2 > 0 and v[0] >= h[(i - 1) // 2][0]:
		if h[(i - 1) // 2][0] == v[0]:
			if v[1] < h[(i - 1) // 2][1]:
				(h[(i - 1) // 2], h[i]) = (h[i], h[(i - 1) // 2])
			else:
				break
		else:
			(h[(i - 1) // 2], h[i]) = (h[i], h[(i - 1) // 2])
		i = (i - 1) // 2

def heap_pop(h):
	l = _len(h) - 1
	(h[0], h[l]) = (h[l], h[0])
	i = 0
	while i * 2 + 2 < l:
		if h[i * 2 + 2][0] > h[i * 2 + 1][0]:
			temp = i * 2 + 2
		elif h[i * 2 + 2][0] == h[i * 2 + 1][0]:
			if h[i * 2 + 2][1] < h[i * 2 + 1][1]:
				temp = i * 2 + 2
			else:
				temp = i * 2 + 1
		else:
			temp = i * 2 + 1
		if h[i][0] < h[temp][0]:
			(h[i], h[temp]) = (h[temp], h[i])
		elif h[i][0] == h[temp][0] and h[i][1] > h[temp][1]:
			(h[i], h[temp]) = (h[temp], h[i])
		else:
			break
		i = temp
	else:
		if i * 2 + 1 < l:
			if h[i][0] < h[i * 2 + 1][0]:
				(h[i], h[i * 2 + 1]) = (h[i * 2 + 1], h[i])
			elif h[i][0] == h[i * 2 + 1][0] and h[i][1] > h[i * 2 + 1][1]:
				(h[i], h[i * 2 + 1]) = (h[i * 2 + 1], h[i])
	el = h[-1]
	h.pop()
	return el

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		a = [0] * n
		h = [(n - 1, 1, n)]
		for i in _range(n):
			(v, l, r) = heap_pop(h)
			if (r - l) % 2 == 0:
				temp = (r + l) // 2
			else:
				temp = (r + l - 1) // 2
			a[temp - 1] = i + 1
			if temp > l:
				heap_push(h, (temp - 1 - l, l, temp - 1))
			if temp < r:
				heap_push(h, (r - (temp + 1), temp + 1, r))
		print(*a)
solution()


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	res = [0] * n
	q = [[1 - n, 0, n - 1]]
	heapq.heapify(q)
	i = 0
	cnt = 0
	while q:
		(x, l, r) = heapq.heappop(q)
		cnt += 1
		if r - l & 1 == 0:
			pos = l + r >> 1
			res[pos] = cnt
			if l <= pos - 1:
				heapq.heappush(q, [l - pos + 1, l, pos - 1])
			if pos + 1 <= r:
				heapq.heappush(q, [pos + 1 - r, pos + 1, r])
		else:
			pos = l + r - 1 >> 1
			res[pos] = cnt
			if pos + 1 <= r:
				heapq.heappush(q, [pos + 1 - r, pos + 1, r])
			if l <= pos - 1:
				heapq.heappush(q, [l - pos + 1, l, pos - 1])
	print(' '.join(map(str, res)))


from heapq import *
for _ in range(int(input())):
	n = int(input())
	h = []
	ans = [0 for i in range(n)]
	i = 1
	heappush(h, [-n, 0, n - 1])
	while h:
		(a, b, c) = heappop(h)
		if b <= c:
			m = (b + c) // 2
			ans[m] = i
			i += 1
			if b <= m - 1:
				heappush(h, [-m + b, b, m - 1])
			if m + 1 <= c:
				heappush(h, [-(c - (m + 1) + 1), m + 1, c])
	print(*ans)


from heapq import *
for _ in range(int(input())):
	n = int(input())
	a = [0] * (n + 1)
	h = []
	heappush(h, (-n, (1, n)))
	val = 1
	while h:
		(length, ind) = heappop(h)
		(l, r) = (ind[0], ind[1])
		length *= -1
		if length <= 0:
			continue
		mid = (l + r) // 2
		a[mid] = val
		val += 1
		heappush(h, (-(mid - l), (l, mid - 1)))
		heappush(h, (-(r - mid), (mid + 1, r)))
	for i in range(1, n + 1):
		print(a[i], end=' ')


import heapq

def diff(r):
	return (r[0] - r[1], r)
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	h = [diff((0, n - 1))]
	heapq.heapify(h)
	i = 1
	while h:
		(d, r) = heapq.heappop(h)
		if r[1] - r[0] + 1 & 1:
			mid = (r[0] + r[1]) // 2
			if r[1] - r[0] > 1:
				heapq.heappush(h, diff((r[0], mid - 1)))
				heapq.heappush(h, diff((mid + 1, r[1])))
		else:
			mid = (r[0] + r[1] - 1) // 2
			heapq.heappush(h, diff((mid + 1, r[1])))
			if r[1] - r[0] > 2:
				heapq.heappush(h, diff((r[0], mid - 1)))
		a[mid] = i
		i += 1
	print(*a)


def dfs(ans, l, r):
	if r - l < 0:
		return
	ans.append((l, r))
	mid = l + (r - l) // 2
	left = (l, mid - 1)
	right = (mid + 1, r)
	dfs(ans, *left)
	dfs(ans, *right)
for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	a = []
	dfs(a, 0, n - 1)
	a.sort(key=lambda x: abs(x[0] - x[1]), reverse=True)
	i = 1
	for (l, r) in a:
		mid = l + (r - l) // 2
		ans[mid] = i
		i += 1
	print(*ans)


import heapq

def fill_zero_array(num):
	array = [0] * num
	heap = [(-num, 0)]
	for i in range(1, num + 1):
		(length, l) = heapq.heappop(heap)
		length = -length
		r = l + length - 1
		mid = (l + r) // 2
		array[mid] = i
		if mid > l:
			heapq.heappush(heap, (-(mid - l), l))
		if mid < r:
			heapq.heappush(heap, (-(r - mid), mid + 1))
	return array
quant = int(input())
inputs = list()
for i in range(quant):
	inputs.append(int(input()))
for i in inputs:
	print(*fill_zero_array(i))


import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
T = int(stdin.readline())
setrecursionlimit(2 ** 20)

def solve(l, r):
	global i, d
	if l > r:
		return
	if r - l + 1 not in d:
		d[r - l + 1] = []
	d[r - l + 1].append(l)
	if l == r:
		a[l] = i
		i += 1
		return
	if (r - l + 1) % 2 == 1:
		a[(l + r) // 2] = i
		s = (l + r) // 2
	else:
		a[(l + r - 1) // 2] = i
		s = (l + r) // 2
	i += 1
	solve(l, s - 1)
	solve(s + 1, r)
for _ in range(T):
	n = int(stdin.readline())
	i = 1
	a = [0] * (n + 1)
	d = {}
	solve(1, n)
	i = 1
	for s in range(n, 0, -1):
		if s not in d:
			continue
		ls = d[s]
		ls.sort()
		for l in ls:
			r = l + s - 1
			if (r - l + 1) % 2 == 1:
				a[(l + r) // 2] = i
			else:
				a[(l + r - 1) // 2] = i
			i += 1
	for h in a[1:]:
		print(h, end=' ')
	print('')


t = int(input())
from collections import defaultdict
import heapq
store = defaultdict(list)
for _ in range(t):
	n = int(input())
	arr = [0] * n
	heap = [(-n, (1, n))]
	if store[n] != []:
		for num in store[n]:
			print(num, end=' ')
		print()
		continue
	heapq.heapify(heap)
	count = 1
	while heap:
		(leng, cord) = heapq.heappop(heap)
		(a, b) = cord
		mid = (a + b) // 2
		if a > b:
			continue
		arr[mid - 1] = count
		count += 1
		if a < mid:
			heapq.heappush(heap, (a - mid, (a, mid - 1)))
		if b > mid:
			heapq.heappush(heap, (mid - b, (mid + 1, b)))
	if store[n] == []:
		store[n].extend(arr)
	for num in arr:
		print(num, end=' ')
	print()


def solve(x, y, index):
	if x > y:
		return
	mid = (x + y) // 2
	index.append([y - x, -1 * x])
	solve(x, mid - 1, index)
	solve(mid + 1, y, index)
for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	index = []
	solve(0, n - 1, index)
	index.sort(reverse=True)
	for i in range(n):
		ind = index[i][0] // 2 - index[i][1]
		ans[ind] = i + 1
	print(*ans)


import heapq
t = int(input())
for i in range(t):
	n = int(input())
	q = []
	heapq.heappush(q, (-n, 0, n - 1))
	i = 1
	a = [None for j in range(n)]
	while q:
		(x, l, r) = heapq.heappop(q)
		mid = (l + r) // 2
		a[mid] = i
		i += 1
		if l != mid:
			heapq.heappush(q, (l - mid, l, mid - 1))
		if r != mid:
			heapq.heappush(q, (mid - r, mid + 1, r))
	print(*a)


import functools
import heapq

class Section:

	def __init__(self, left, right):
		self.left = left
		self.right = right
		self.size = right - left
		if (right - left + 1) % 2 != 0:
			self.aim = (left + right) // 2
		else:
			self.aim = (left + right - 1) // 2

	@functools.total_ordering
	def __lt__(self, other):
		if self.size > other.size:
			return True
		if self.size < other.size:
			return False
		return self.left < other.left

	@functools.total_ordering
	def __eq__(self, other):
		return self.size == other.size and self.left == self.right

def solution(n):
	h = []
	res = [0 for i in range(n)]
	cnt = 1
	sec = Section(0, n - 1)
	heapq.heappush(h, sec)
	while len(h) > 0:
		current = heapq.heappop(h)
		res[current.aim] = cnt
		cnt += 1
		if current.left != current.aim:
			new_sec1 = Section(current.left, current.aim - 1)
			heapq.heappush(h, new_sec1)
		if current.right != current.aim:
			new_sec2 = Section(current.aim + 1, current.right)
			heapq.heappush(h, new_sec2)
	print(' '.join(map(str, res)))
inp = int(input())
for _ in range(inp):
	n = int(input())
	solution(n)


import heapq

def solve(k):
	stack = [(-k, 0, k - 1)]
	heapq.heapify(stack)
	res = ['x' for _ in range(k)]
	cnt = 0
	while stack:
		cnt += 1
		(length, start, end) = heapq.heappop(stack)
		length = -length
		if length % 2 == 1:
			mid_point = (start + end) // 2
			res[mid_point] = cnt
			if not start == end:
				heapq.heappush(stack, (-(mid_point - start), start, mid_point - 1))
				heapq.heappush(stack, (-(mid_point - start), mid_point + 1, end))
		else:
			mid_point = (start + end - 1) // 2
			res[mid_point] = cnt
			if length == 2:
				heapq.heappush(stack, (-1, end, end))
			else:
				heapq.heappush(stack, (-(length // 2 - 1), start, mid_point - 1))
				heapq.heappush(stack, (-(length // 2), mid_point + 1, end))
	return ' '.join([str(x) for x in res])
strr = input()
for _ in range(int(strr)):
	k = int(input())
	print(solve(k))


import heapq as pq

def solve():
	n = int(input())
	arr = [0] * n
	q = [[-n, 0, n - 1]]
	i = 0
	while i < n:
		i += 1
		(x, y, z) = pq.heappop(q)
		x = -x
		idx = (y + z) // 2
		arr[idx] = i
		if idx > y:
			pq.heappush(q, [y - idx, y, idx - 1])
		if z > idx:
			pq.heappush(q, [idx - z, idx + 1, z])
	print(' '.join(list(map(str, arr))))
T = int(input())
for i in range(T):
	solve()


import heapq as heap
for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	ar = []
	heap.heappush(ar, (n, 0, n - 1))
	for i in range(1, n + 1):
		(size, l, h) = heap.heappop(ar)
		if (h - l + 1) % 2 == 0:
			mid = (l + h - 1) // 2
			ans[mid] = i
		else:
			mid = (l + h) // 2
			ans[mid] = i
		if h - mid > 0:
			heap.heappush(ar, (-(h - mid), mid + 1, h))
		if mid - l > 0:
			heap.heappush(ar, (-(mid - l), l, mid - 1))
	print(*ans)


from heapq import heappush, heapify, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * n
	raj = []
	heapify(raj)
	heappush(raj, (n * -1, 0, n - 1))
	put = 1
	while len(raj) != 0:
		x = heappop(raj)
		tot = x[0] * -1
		l = x[1]
		r = x[2]
		if tot % 2 == 0:
			mid = (l + r - 1) // 2
		else:
			mid = (l + r) // 2
		arr[mid] = put
		put += 1
		if l <= mid - 1:
			heappush(raj, ((mid - 1 - l + 1) * -1, l, mid - 1))
		if mid + 1 <= r:
			heappush(raj, ((r - (mid + 1) + 1) * -1, mid + 1, r))
	print(*arr)


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	l = [0] * n
	wart = [[-n, 0, n - 1]]
	for x in range(1, n + 1):
		(curr_len, curr_beg, curr_end) = heapq.heappop(wart)
		curr_mid = (curr_beg + curr_end) // 2
		l[curr_mid] = x
		if abs(curr_len) > 2:
			heapq.heappush(wart, [-(curr_mid - curr_beg), curr_beg, curr_mid - 1])
			heapq.heappush(wart, [-(curr_end - curr_mid), curr_mid + 1, curr_end])
		elif abs(curr_len) == 2:
			heapq.heappush(wart, [-1, curr_mid + 1, curr_mid + 1])
	print(' '.join((str(x) for x in l)))


import collections
import operator
from heapq import heappush, heappop
for _ in range(int(input())):
	n = int(input())
	left = 0
	right = n - 1
	s = [0] * n
	count = 1
	queue = []
	queue.append((-right, left, right))
	while queue and len(queue) > 0:
		(_, left, right) = heappop(queue)
		idx = (left + right) // 2
		s[idx] = count
		count += 1
		if idx > left:
			heappush(queue, (left - idx, left, idx - 1))
		if idx < right:
			heappush(queue, (idx - right, idx + 1, right))
	print(*s)


from sys import stdin, stdout
import heapq
for testcases in range(int(stdin.readline())):
	n = int(stdin.readline())
	if n == 1:
		print(1)
	elif n == 2:
		print(1, 2)
	else:
		k = 1
		arr = [0 for i in range(n)]
		store = [(-n, (0, n - 1))]
		chance = 1
		heapq.heapify(store)
		while len(store) > 0:
			value = heapq.heappop(store)
			left = value[1][0]
			right = value[1][1]
			if left > right:
				continue
			if left == right:
				arr[left] = k
				k += 1
			elif (right - left + 1) % 2 == 0:
				mid = (left + right - 1) // 2
				arr[mid] = k
				k += 1
				heapq.heappush(store, (-(right - mid), (mid + 1, right)))
				heapq.heappush(store, (-(mid - left), (left, mid - 1)))
			else:
				mid = (left + right) // 2
				arr[mid] = k
				k += 1
				heapq.heappush(store, (-(right - mid), (mid + 1, right)))
				heapq.heappush(store, (-(mid - left), (left, mid - 1)))
		for i in arr:
			stdout.write(str(i) + ' ')
		stdout.write('\n')


import sys
import os
import heapq
try:
	path = './file/input.txt'
	if os.path.exists(path):
		sys.stdin = open(path, 'r')
except:
	pass

class Node:

	def __init__(self, n, left, right):
		self.left = left
		self.right = right
		self.weight = n - right + left

	def __lt__(self, other):
		return self.weight < other.weight or (self.weight == other.weight and self.left < other.left)
t = int(input())
for _ in range(t):
	n = int(input())
	q = []
	result = [0] * (n + 1)
	heapq.heappush(q, Node(n, 1, n))
	index = 1
	while True:
		if len(q) == 0:
			break
		node = heapq.heappop(q)
		if node is None:
			break
		if node.left == node.right:
			result[node.left] = index
			index += 1
		else:
			middle = int((node.left + node.right) / 2)
			result[middle] = index
			index += 1
			if node.left != middle:
				heapq.heappush(q, Node(n, node.left, middle - 1))
			heapq.heappush(q, Node(n, middle + 1, node.right))
	print(' '.join((str(i) for i in result[1:])))


import heapq as heap
t = int(input())
for i in range(t):
	n = int(input())
	ans = [0] * n
	h = [(-n, 0, n - 1)]
	heap.heapify(h)
	i = 1
	while len(h) > 0:
		(length, l, r) = heap.heappop(h)
		mid = (l + r) // 2
		ans[mid] = i
		i += 1
		if l < mid:
			heap.heappush(h, (-(mid - l), l, mid - 1))
		if r > mid:
			heap.heappush(h, (-(r - mid), mid + 1, r))
	for j in range(n):
		print(ans[j], end=' ')


from heapq import heappush as hpush, heappop as hpop
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * (n + 1)
	q = []
	hpush(q, (-n, 1, n))
	val = 1
	while len(q) > 0 and val <= n:
		(wt, l, r) = hpop(q)
		if (r - l + 1) % 2 == 1:
			i = (l + r) // 2
		else:
			i = (l + r - 1) // 2
		a[i] = val
		val += 1
		if i - l >= 1:
			hpush(q, (l - i, l, i - 1))
		if r - i <= n:
			hpush(q, (i - r, i + 1, r))
	print(*a[1:])


t = int(input())
import math

def m(l, r):
	if r < l:
		return
	if l == r:
		ll[1].append(l)
		return
	d = (r + l) // 2
	ll[r - l + 1].append(d)
	m(l, d - 1)
	m(d + 1, r)
for _ in range(t):
	n = int(input())
	a = [0 for i in range(n)]
	ll = [[] for i in range(n + 2)]
	m(0, n - 1)
	c = 1
	for i in range(len(ll) - 1, -1, -1):
		ll[i].sort()
		for j in ll[i]:
			a[j] = c
			c += 1
	print(*a)


from sys import stdin as si
from heapq import heappop as hpo, heappush as hpu

def evaluate(n):
	x = []
	hpu(x, (-n, (0, n - 1)))
	ans = [0] * n
	for j in range(1, n + 1):
		(a, cur) = hpo(x)
		index = (cur[0] + cur[1]) // 2
		ans[index] = j
		if cur[0] < index:
			hpu(x, (-1 * (index - 1 - cur[0]), (cur[0], index - 1)))
		if cur[1] > index:
			hpu(x, (-1 * (cur[1] - (index + 1)), (index + 1, cur[1])))
	print(*ans)
for i in range(int(si.readline().strip())):
	n = int(si.readline().strip())
	evaluate(n)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]
spf_sieve()

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
import heapq as hp
for _ in range(int(input())):
	n = int(input())
	q = []
	ans = [0] * n
	hp.heappush(q, (-n, 0, n - 1))
	count = 1
	while q:
		this = hp.heappop(q)
		(l, r) = (this[1], this[2])
		mid = (l + r) // 2
		ans[mid] = count
		count += 1
		(l1, r1) = (l, mid - 1)
		(l2, r2) = (mid + 1, r)
		if l1 <= r1:
			hp.heappush(q, (-(r1 - l1 + 1), l1, r1))
		if l2 <= r2:
			hp.heappush(q, (-(r2 - l2 + 1), l2, r2))
	print(*ans)


from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	lst = [(-n, 0, n - 1)]
	a = [0] * n
	ct = 1
	while ct <= n:
		(c, l, r) = heappop(lst)
		mid = (r + l) // 2
		a[mid] = ct
		if mid > l:
			heappush(lst, (l - mid, l, mid - 1))
		if mid < r:
			heappush(lst, (mid - r, mid + 1, r))
		ct += 1
	print(*a)


from collections import Counter, defaultdict, deque
import heapq as hq
from math import *
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	h = [(-n, 0, n - 1)]
	res = [0] * n
	i = 1
	while len(h):
		nxt = hq.heappop(h)
		mid = (nxt[1] + nxt[2]) // 2
		res[mid] = i
		i += 1
		r1 = (nxt[1] - mid, nxt[1], mid - 1)
		r2 = (mid - nxt[2], mid + 1, nxt[2])
		if r1[0] < 0:
			hq.heappush(h, r1)
		if r2[0] < 0:
			hq.heappush(h, r2)
	print(*res)
tt = int(input())
for test in range(tt):
	solve()


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	v = [0] * n
	cnt = 1
	pq = [(-n, (1, n))]
	heapq.heapify(pq)
	while len(pq):
		x = heapq.heappop(pq)
		l = x[1][0]
		r = x[1][1]
		if l > r:
			continue
		tmp = (l + r) // 2
		v[tmp - 1] = cnt
		cnt += 1
		if tmp - l:
			heapq.heappush(pq, (-(tmp - l), (l, tmp - 1)))
		if r - tmp:
			heapq.heappush(pq, (-(r - tmp), (tmp + 1, r)))
	print(*v)


import sys
input = sys.stdin.readline
from collections import *
from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = [-1] * n
	pq = [(n, 0, n - 1)]
	now = 1
	while now <= n:
		(_, l, r) = heappop(pq)
		if (r - l) % 2 == 0:
			m = (l + r) // 2
		else:
			m = (l + r - 1) // 2
		a[m] = now
		now += 1
		heappush(pq, (-(m - l), l, m - 1))
		heappush(pq, (-(r - m), m + 1, r))
	print(*a)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())

def solve(l, r):
	if l > r:
		return
	m = (l + r) // 2
	lst1[m] = (l - r, m)
	solve(l, m - 1)
	solve(m + 1, r)
for _ in range(num):
	n = int(z())
	lst = [0] * n
	lst1 = [0] * n
	solve(0, n - 1)
	for (i, j) in enumerate(sorted(lst1)):
		lst[j[1]] = i + 1
	print(*lst)


def array_building(l, r, result):
	if l > r:
		return
	elif l == r:
		result[l] = 1
		return
	num = (l + r) // 2
	result[num] = r - l + 1
	array_building(l, num - 1, result)
	array_building(num + 1, r, result)

def solve():
	n = int(input())
	a = [0] * n
	result = [0] * n
	array_building(0, n - 1, result)
	for i in range(n):
		result[i] = (result[i], i)
	result.sort(key=lambda x: (-x[0], x[1]))
	for i in range(n):
		a[result[i][1]] = i + 1
	print(' '.join(map(str, a)))

def main():
	for _ in range(int(input())):
		solve()
main()


from heapq import heappush, heappop
import os
import sys
from io import BytesIO, IOBase

def inpint():
	return int(input())

def getnum(l, r):
	if (r - l + 1) % 2 == 0:
		return (l + r - 1) // 2
	else:
		return (l + r) // 2

def gettup(l, r):
	return (-(r - l + 1), l, r)

def main():
	t = inpint()
	for _ in range(t):
		n = inpint()
		li = [0] * n
		(l, r) = (1, n)
		Q = [gettup(l, r)]
		for i in range(1, n + 1):
			d = heappop(Q)
			(l, r) = (d[1], d[2])
			num = getnum(l, r)
			li[num - 1] = i
			(l1, r2) = (l, r)
			(r1, l2) = (num - 1, num + 1)
			heappush(Q, gettup(l1, r1))
			heappush(Q, gettup(l2, r2))
		print(*li)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
import math
from collections import Counter, defaultdict
import heapq
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass

def takeInput():
	return [int(x) for x in input().strip().split()]
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = [0] * n
	status = True
	i = 1
	lengths = [(-(n - 1), 0)]
	heapq.heapify(lengths)
	for i in range(1, n + 1):
		(l, si) = heapq.heappop(lengths)
		l *= -1
		ei = si + l
		mid = (si + ei) // 2
		l1 = mid - 1 - si
		if l1 >= 0:
			heapq.heappush(lengths, (-l1, si))
		l2 = ei - (mid + 1)
		if l2 >= 0:
			heapq.heappush(lengths, (-l2, mid + 1))
		a[mid] = i
		i += 1
	print(*a)


import sys
import heapq

def answer(n):
	heap = []
	ans = [0 for _ in range(n)]
	l = 0
	r = n - 1
	w = -(r - l + 1)
	mid = (r + l) // 2
	heapq.heappush(heap, (w, mid, l, r))
	for ctr in range(1, n + 1):
		tup = heapq.heappop(heap)
		l = tup[2]
		r = tup[3]
		mid = tup[1]
		ans[mid] = ctr
		ll = l
		lr = mid - 1
		lmid = (lr + ll) // 2
		lw = -(lr - ll + 1)
		heapq.heappush(heap, (lw, lmid, ll, lr))
		rl = mid + 1
		rr = r
		rmid = (rr + rl) // 2
		rw = -(rr - rl + 1)
		heapq.heappush(heap, (rw, rmid, rl, rr))
	return ans

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		print(*answer(n))
		t -= 1
	return
main()


t = int(input())
import heapq
for _ in range(t):
	n = int(input())
	pq = []
	ans = [0] * n
	pq.append((n, 1, n))
	cur = 1
	while pq:
		(ll, l, r) = heapq.heappop(pq)
		ll = ll * -1
		if ll == 1:
			ans[l - 1] = cur
		elif ll % 2 == 0:
			mid = (l + r - 1) // 2
			ans[mid - 1] = cur
			if mid - l > 0:
				heapq.heappush(pq, (-mid + l, l, mid - 1))
			if r - mid > 0:
				heapq.heappush(pq, (-r + mid, mid + 1, r))
		else:
			mid = (l + r) // 2
			ans[mid - 1] = cur
			if mid - l > 0:
				heapq.heappush(pq, (-mid + l, l, mid - 1))
			if r - mid > 0:
				heapq.heappush(pq, (-r + mid, mid + 1, r))
		cur += 1
	print(' '.join(map(str, ans)))


from heapq import *
import sys
t = int(input())
for _ in range(t):
	n = int(sys.stdin.readline())
	ans = [0 for i in range(n + 1)]
	hp = [[-n, 1, n]]
	heapify(hp)
	for i in range(n):
		(sz, l, r) = heappop(hp)
		mid = (l + r) // 2
		ans[mid] = i + 1
		if 0 < mid - 1 and l <= mid - 1:
			heappush(hp, [-(mid - 1 - l + 1), l, mid - 1])
		if mid + 1 <= n and mid + 1 <= r:
			heappush(hp, [-(r - (mid + 1) + 1), mid + 1, r])
	for i in range(1, len(ans)):
		sys.stdout.write(str(ans[i]) + ' ')
	sys.stdout.write('\n')


import heapq
t = int(input())
while t != 0:
	n = int(input())
	heap = [[-(n - 1), 0, n - 1]]
	ans = [0 for i in range(n)]
	count = 1
	while count <= n:
		p = heapq.heappop(heap)
		s = p[1]
		l = p[2]
		mid = (s + l) // 2
		ans[mid] = count
		count += 1
		if mid - s - 1 < 0:
			pass
		else:
			new_list1 = [-(mid - s - 1), s, mid - 1]
			heapq.heappush(heap, new_list1)
		if l - mid - 1 < 0:
			pass
		else:
			new_list2 = [-(l - mid - 1), mid + 1, l]
			heapq.heappush(heap, new_list2)
	print(*ans)
	t -= 1


import heapq
a = int(input())
for z in range(a):
	b = int(input())
	c = [0] * b
	e = []
	for y in range(b + 1):
		e.append([])
	e[b].append(0)
	h = b
	for y in range(1, b + 1):
		while 1:
			if e[h] != []:
				break
			h = h - 1
		f = heapq.heappop(e[h])
		d = (h - 1) // 2 + f
		c[d] = y
		heapq.heappush(e[(h - 1) // 2], f)
		heapq.heappush(e[h - (h - 1) // 2 - 1], d + 1)
	print(*c)


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
import heapq as hq
t = int(input())
for tt in range(t):
	n = int(input())
	a = [0] * n
	q = [(-(n - 1), 0, n - 1)]
	for v in range(1, n + 1):
		(x, l, r) = hq.heappop(q)
		if l > r:
			continue
		i = (r + l) // 2
		a[i] = v
		(newl, newr) = (i + 1, i - 1)
		hq.heappush(q, (l - newr, l, newr))
		hq.heappush(q, (newl - r, newl, r))
	print(' '.join(map(str, a)) + '\n')


import heapq as hq
t = int(input())
for _ in range(t):
	n = int(input())
	h = [(-n, 1, n)]
	hq.heapify(h)
	x = 1
	ans = [0] * (n + 1)
	while h:
		(len, l, r) = hq.heappop(h)
		mid = (l + r) // 2
		ans[mid] = x
		x += 1
		if l < mid:
			hq.heappush(h, [-(mid - l), l, mid - 1])
		if r > mid:
			hq.heappush(h, [-(r - mid), mid + 1, r])
	for i in ans[1:]:
		print(i, end=' ')
	print()


import sys

def answer(n):
	widths = [[] for _ in range(n + 1)]
	ans = [0 for _ in range(n)]
	widths[n].append(0)
	ctr = 1
	for w in range(n, 0, -1):
		ls = widths[w]
		ls.sort()
		for l in ls:
			mid = (l + (l + w - 1)) // 2
			ans[mid] = ctr
			ctr += 1
			if w > 1:
				lw = mid - 1 - l + 1
				widths[lw].append(l)
				rw = l + w - (mid + 1)
				widths[rw].append(mid + 1)
	return ans

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		print(*answer(n))
		t -= 1
	return
main()


from heapq import heappush, heappop
import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)

def main():
	ntc = next(ints)
	for tc in range(1, ntc + 1):
		n = next(ints)
		ans = [0] * n
		q = [(-n, 0)]
		i = 0
		while q:
			(k, l) = heappop(q)
			r = -k + l
			mid = (l + r - 1) // 2
			ans[mid] = i = i + 1
			if mid > l:
				heappush(q, (l - mid, l))
			if mid + 1 < r:
				heappush(q, (mid + 1 - r, mid + 1))
		print(*ans)
	return
main()


import atexit
import io
import sys
from collections import deque
from heapq import *
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def pur(a, b):
	if (b - a + 1) % 2 == 1:
		m = (b + a) // 2
	else:
		m = (b + a - 1) // 2
	return m
tc = int(input())
for zzz in range(tc):
	n = int(input())
	arr = []
	arr.append(0)
	for i in range(n):
		arr.append(0)
	dq1 = deque()
	dq2 = []
	dq1.append((1, n))
	while len(dq1) > 0:
		tem = dq1.popleft()
		a = tem[0]
		b = tem[1]
		m = pur(a, b)
		dq2.append((-(tem[1] - tem[0]), m))
		if a != b:
			if a != m:
				dq1.append((a, m - 1))
			if b != m:
				dq1.append((m + 1, b))
	heapify(dq2)
	i = 1
	while len(dq2) > 0:
		r = heappop(dq2)
		d = r[1]
		arr[d] = i
		i += 1
	printed = []
	for i in range(1, n + 1):
		printed.append(str(arr[i]))
	print(' '.join(printed))


from sys import stdin
import heapq
for t in range(int(stdin.readline())):
	n = int(stdin.readline())
	ans = [0] * n
	a = []
	heapq.heapify(a)
	heapq.heappush(a, (-n, 0, n - 1))
	for i in range(1, n + 1):
		cur = heapq.heappop(a)
		index = (cur[1] + cur[2]) // 2
		ans[index] = i
		p1 = index - cur[1]
		p2 = cur[2] - index
		heapq.heappush(a, (-p1, cur[1], index - 1))
		heapq.heappush(a, (-p2, index + 1, cur[2]))
	print(*ans)


import heapq as hp
for _ in range(int(input())):
	n = int(input())
	ans = [0 for i in range(n + 1)]
	k = 1
	arr = [[-n, 1, n]]
	hp.heapify(arr)
	while len(arr) != 0:
		(s, l, r) = arr[0]
		hp.heappop(arr)
		m = (l + r) // 2
		ans[m] = k
		k += 1
		if l <= m - 1:
			hp.heappush(arr, [-(m - l), l, m - 1])
		if r >= m + 1:
			hp.heappush(arr, [-(r - m), m + 1, r])
	print(*ans[1:])


import heapq
from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * (n + 1)
	h = []
	heapq.heappush(h, (-n, 1, n))
	for i in range(1, n + 1):
		e = heapq.heappop(h)
		(_, l, r) = e
		if (r - l + 1) % 2 != 0:
			a[(l + r) // 2] = i
			new_ind = (l + r) // 2
		else:
			a[(l + r - 1) // 2] = i
			new_ind = (l + r - 1) // 2
		if new_ind != l:
			heapq.heappush(h, (l - new_ind, l, new_ind - 1))
		if new_ind != r:
			heapq.heappush(h, (new_ind - r, new_ind + 1, r))
	print(' '.join([str(x) for x in a[1:]]))


from heapq import heapify, heappop, heappush

def solver(n):
	(result, lst, k) = ([0] * (n + 1), list(), 1)
	heapify(lst)
	heappush(lst, (n, 1, n))
	while k <= n:
		(ll, l, r) = heappop(lst)
		mid = (l + r) // 2
		result[mid] = k
		k += 1
		if mid - l > 0:
			heappush(lst, (-(mid - l), l, mid - 1))
		if r - mid > 0:
			heappush(lst, (-(r - mid), mid + 1, r))
	return result[1:]
for _ in range(int(input())):
	m = int(input())
	print(*solver(m))


def decompose(cur):
	return (cur[1] - (-cur[0] - 1) // 2, cur[1] + (-cur[0] + 2) // 2)

def getMid(l, r):
	return (l + r - 1) // 2
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	q = list()
	tot = 0
	a = [0 for i in range(n)]
	q.append((-n, getMid(0, n)))
	while len(q) > 0:
		q2 = sorted(q)
		mx = -q2[0][0]
		q.clear()
		for cur in q2:
			if mx > 1 and cur[0] == -1:
				q.append(cur)
				continue
			tot += 1
			a[cur[1]] = tot
			(e, b) = (cur[1], cur[1] + 1)
			(l, r) = decompose(cur)
			if e > l:
				q.append((-e + l, getMid(l, e)))
			if r > b:
				q.append((-r + b, getMid(b, r)))
	for i in a:
		print(i, end=' ')
	print('')


import heapq
import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for i in range(t):
	n = int(input())
	if n % 2 == 0:
		ok = False
	ans = [0] * (n + 1)
	store = []
	store.append([n, 1, n])
	i = 1
	while store:
		(a, b, c) = heapq.heappop(store)
		mid = (b + c) // 2
		ans[mid] = i
		i += 1
		if i > n:
			break
		if b <= mid - 1:
			heapq.heappush(store, [-1 * (mid - b), b, mid - 1])
		if mid + 1 <= c:
			heapq.heappush(store, [-1 * (c - mid), mid + 1, c])
	ans = ' '.join(map(str, ans[1:]))
	sys.stdout.write(ans + '\n')


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
from heapq import heapify, heappop as pp, heappush as pus
for _ in range(int(input())):
	n = int(input())
	res = [0] * (n + 1)
	s = [(-n, 1, n)]
	for i in range(1, n + 1):
		(ln, l, r) = pp(s)
		if r - l + 1 & 1:
			mid = l + r >> 1
		else:
			mid = l + r - 1 >> 1
		res[mid] = i
		pus(s, (-(mid - l), l, mid - 1))
		pus(s, (-(r - mid), mid + 1, r))
	print(*res[1:])


def b(l, r):
	if l > r:
		return
	mid = (l + r) // 2
	arr.append((l - r, mid))
	b(l, mid - 1)
	b(mid + 1, r)
for _ in range(int(input())):
	n = int(input())
	arr = []
	res = [0] * n
	b(0, n - 1)
	for (i, j) in enumerate(sorted(arr)):
		res[j[1]] = i + 1
	print(*res)


from math import ceil
import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	hp = [(n, 1, n)]
	res = [''] * n
	i = 1
	while hp:
		(length, l, r) = heapq.heappop(hp)
		length *= -1
		if length % 2 == 1:
			mid = (l + r) // 2
		else:
			mid = (l + r - 1) // 2
		res[mid - 1] = str(i)
		if mid - l > 0:
			heapq.heappush(hp, (-(mid - l), l, mid - 1))
		if r - mid > 0:
			heapq.heappush(hp, (-(r - mid), mid + 1, r))
		i += 1
	print(' '.join(res))


import heapq
import sys
from typing import List

def solve(nb: int) -> List[int]:
	result = [0] * nb
	intervals = [(-nb, 0)]
	for i in range(nb):
		(zeros, idx) = heapq.heappop(intervals)
		zeros *= -1
		z_idx = idx + (zeros - 1) // 2
		result[z_idx] = i + 1
		zeros -= 1
		h = zeros // 2
		heapq.heappush(intervals, (-h, idx))
		heapq.heappush(intervals, (h - zeros, z_idx + 1))
	return result

def do_job():
	T = int(input())
	for _testcase in range(T):
		n = int(input())
		result = solve(n)
		print(*result)
do_job()


import heapq as heap
for _ in range(int(input())):
	n = int(input())
	A = [0] * n
	L = []
	Heap = heap.heappush(L, (n, 0, n - 1))
	for i in range(1, n + 1):
		(ar, l, h) = heap.heappop(L)
		if (h - l + 1) % 2 == 0:
			mid = (h + l - 1) // 2
			A[mid] = i
		else:
			mid = (h + l) // 2
			A[mid] = i
		if h - mid > 0:
			heap.heappush(L, (mid - h, mid + 1, h))
		if mid - l > 0:
			heap.heappush(L, (l - mid, l, mid - 1))
	print(*A)


import sys
import heapq

def answer(n):
	heap = []
	ans = [0 for _ in range(n)]
	l = 0
	w = n - 1
	heapq.heappush(heap, (-w, l))
	for ctr in range(1, n + 1):
		tup = heapq.heappop(heap)
		l = tup[1]
		w = -tup[0]
		r = l + w
		mid = l + w // 2
		ans[mid] = ctr
		lw = mid - 1 - l
		heapq.heappush(heap, (-lw, l))
		rw = r - (mid + 1)
		heapq.heappush(heap, (-rw, mid + 1))
	return ans

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		print(*answer(n))
		t -= 1
	return
main()


import heapq
test = int(input())
for _ in range(0, test):
	n = int(input())
	ara = [0 for i in range(0, n)]
	subara = [(n * -1, 1)]
	heapq.heapify(subara)
	for itr in range(1, n + 1):
		(k, l) = heapq.heappop(subara)
		k = k * -1
		r = l + k - 1
		if k % 2 == 1:
			i = (l + r) // 2
		else:
			i = (l + r - 1) // 2
		ara[i - 1] = itr
		if i > l:
			heapq.heappush(subara, ((i - l) * -1, l))
		if i < r:
			heapq.heappush(subara, ((r - i) * -1, i + 1))
	ans = ' '.join(map(str, ara))
	print(ans)


import heapq

def heap_pop(a, b):
	if a <= b:
		heapq.heappush(hp, (a - b, (a, b)))
for _ in range(int(input())):
	n = int(input())
	hp = [(-n, (0, n - 1))]
	heapq.heapify(hp)
	i = 1
	a = [0] * n
	while hp:
		(length, (l, r)) = heapq.heappop(hp)
		length = -length
		mid = (l + r) // 2
		a[mid] = i
		i += 1
		heap_pop(l, mid - 1)
		heap_pop(mid + 1, r)
	print(*a)


for _ in range(int(input())):
	n = int(input())
	d = {n: [0]}
	(s, r) = ([n], [0] * n)
	i = 1
	while i <= n:
		s = sorted(s)
		n1 = s.pop()
		for j in sorted(d[n1]):
			(start, stop) = (j, j + n1)
			if n1 % 2 == 0:
				mid = (start + stop - 1) // 2
			else:
				mid = (start + stop) // 2
			r[mid] = i
			i += 1
			if mid - j in d:
				d[mid - j] += [j]
			else:
				d[mid - j] = [j]
			if stop - 1 - mid in d:
				d[stop - 1 - mid] += [mid + 1]
			else:
				d[stop - 1 - mid] = [mid + 1]
			if mid - j not in s:
				s += [mid - j]
			if stop - 1 - mid not in s:
				s += [stop - 1 - mid]
		del d[n1]
	print(*r)


import heapq

def bfs():
	n = int(input())
	a = [0 for i in range(0, n + 1)]
	cnt = 1
	subara = [(-n, 1)]
	heapq.heapify(subara)
	for itr in range(1, n + 1):
		now = heapq.heappop(subara)
		l = now[1]
		r = now[1] + -now[0] - 1
		f = -now[0] % 2 == 0
		id = (l + r - f) // 2
		a[id] = cnt
		cnt += 1
		if id != l:
			heapq.heappush(subara, (-(id - l), l))
		if id != r:
			heapq.heappush(subara, (-(r - id), id + 1))
	for i in range(1, n + 1):
		print(a[i], end=' ')
	print('')
t = int(input())
while t >= 1:
	t -= 1
	bfs()


import heapq
t = int(input())

class ListNode:

	def __init__(self, l, r):
		self.l = l
		self.r = r

	def __lt__(self, other):
		(x1, y1) = (self.l, self.r)
		(x2, y2) = (other.l, other.r)
		(dia1, dia2) = (y1 - x1, y2 - x2)
		if dia1 > dia2:
			return True
		elif dia1 < dia2:
			return False
		else:
			return x1 < x2

def solve(n):
	a = [0] * n
	queue = []
	heapq.heappush(queue, ListNode(0, n - 1))
	idx = 1
	while queue:
		node = heapq.heappop(queue)
		(l, r) = (node.l, node.r)
		k = 0
		if (r - l + 1) % 2 == 1:
			a[(l + r) // 2] = idx
			k = (l + r) // 2
		else:
			a[(l + r - 1) // 2] = idx
			k = (l + r - 1) // 2
		idx += 1
		if l == r:
			continue
		(l1, r1) = (l, k - 1)
		(l2, r2) = (k + 1, r)
		if r2 - l2 >= 0:
			heapq.heappush(queue, ListNode(l2, r2))
		if r1 - l1 >= 0:
			heapq.heappush(queue, ListNode(l1, r1))
	print(' '.join(list(map(str, a))))
for _ in range(t):
	n = int(input())
	solve(n)


for _ in range(int(input())):
	n = int(input())
	rep = [0 for i in range(n)]
	fila = [(n - 1, 0, n - 1)]
	for i in range(n):
		(_, a, b) = fila[i]
		pos = (a + b) // 2
		bNew = pos - 1
		aNew = pos + 1
		if bNew - a >= 0:
			fila.append((bNew - a, a, bNew))
		if b - aNew >= 0:
			fila.append((b - aNew, aNew, b))
	newVec = []
	for (tam, a, b) in fila:
		newVec.append((tam, -((a + b) // 2)))
	newVec.sort(reverse=True)
	for i in range(n):
		(tam, pos) = newVec[i]
		rep[-pos] = i + 1
	for i in rep:
		print(i, end=' ')
	print()


import heapq
import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	n = int(inp())
	a = [0] * n
	i = 1
	q = [(-n, 1, n)]
	while q:
		rmv = heapq.heappop(q)
		l = rmv[1]
		r = rmv[2]
		if rmv[1] > rmv[2]:
			continue
		if (rmv[1] + rmv[2]) % 2 == 0:
			idx = (rmv[1] + rmv[2]) // 2
			a[idx - 1] = i
			i += 1
		else:
			idx = (rmv[1] + rmv[2] - 1) // 2
			a[idx - 1] = i
			i += 1
		if l <= idx - 1:
			heapq.heappush(q, (l - idx, l, idx - 1))
		if r >= idx + 1:
			heapq.heappush(q, (idx - r, idx + 1, r))
	print(*a)


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	cand = []
	q = []
	heapq.heappush(q, (-n, 1))
	while len(q) != 0:
		(s, l) = heapq.heappop(q)
		s *= -1
		if s == 1:
			cand.append([s, l])
		elif s == 2:
			cand.append([s, l])
			heapq.heappush(q, (-1, l + 1))
		else:
			cand.append([s, l])
			if s % 2 == 0:
				heapq.heappush(q, (-(s // 2 - 1), l))
				heapq.heappush(q, (-(s // 2), l + s // 2))
			else:
				heapq.heappush(q, (-(s // 2), l))
				heapq.heappush(q, (-(s // 2), l + (s + 1) // 2))
	cand = sorted(cand, key=lambda x: x[1])
	cand = sorted(cand, reverse=True, key=lambda x: x[0])
	ans = [0] * n
	for i in range(n):
		pos = (cand[i][0] - 1) // 2 + cand[i][1]
		ans[pos - 1] = i + 1
	print(*ans)


import heapq
d = []
heapq.heapify(d)
T = int(input())
for _ in range(T):
	N = int(input())
	que = [0 for i in range(N)]
	inf = 10 ** 10
	heapq.heappush(d, (-(N - 1) * inf, 0, N - 1))
	cnt = 1
	for _ in range(N):
		x = heapq.heappop(d)
		(weight, left, right) = x
		K = left + right
		if left < right:
			if left <= K // 2 - 1:
				heapq.heappush(d, (-inf * (K // 2 - 1 - left) + left, left, K // 2 - 1))
			if K // 2 + 1 <= right:
				heapq.heappush(d, (-inf * (right - K // 2 - 1) + K // 2 + 1, K // 2 + 1, right))
		que[K // 2] = cnt
		cnt += 1
	print(*que)


import sys
import heapq as hq
readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	n = ni()
	a = [0] * n
	q = [(-n, 0, n - 1)]
	for i in range(n):
		(v, l, r) = hq.heappop(q)
		m = (l + r) // 2
		a[m] = i + 1
		hq.heappush(q, (-(m - l), l, m - 1))
		hq.heappush(q, (-(r - m), m + 1, r))
	print(*a)
T = ni()
for _ in range(T):
	solve()


from heapq import *

def solve(x):
	hp = []
	(left, right) = (0, x - 1)
	heappush(hp, [-(right - left + 1), left, right])
	ans = [0] * x
	for i in range(x):
		(length, l, r) = heappop(hp)
		mid = (l + r) // 2
		ans[mid] = i + 1
		(left, right) = (l, mid - 1)
		(left1, right1) = (mid + 1, r)
		(l1, l2) = (right - left + 1, right1 - left1 + 1)
		if mid != 0:
			if l <= mid - 1:
				heappush(hp, [-l1, l, mid - 1])
		if mid != x - 1:
			if mid + 1 <= r:
				heappush(hp, [-l2, mid + 1, r])
	return ans
T = int(input())
for _ in range(T):
	N = int(input())
	print(*solve(N))


import os
import sys
from io import BytesIO, IOBase
import heapq

class HeapNode:

	def __init__(self, i, j):
		self.i = i
		self.j = j

def heapKey(a, b):
	countA = a.j - a.i + 1
	countB = b.j - b.i + 1
	if countA == countB:
		return a.i < b.i
	else:
		return countA > countB
setattr(HeapNode, '__lt__', lambda self, other: heapKey(self, other))

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		out = [0] * n
		i = 1
		heap = list()
		heapq.heappush(heap, HeapNode(0, n - 1))
		while heap:
			x = heapq.heappop(heap)
			count = x.j - x.i + 1
			if count % 2 == 0:
				pivot = (x.i + x.j - 1) // 2
			else:
				pivot = (x.i + x.j) // 2
			out[pivot] = i
			i += 1
			(l1, r1) = (x.i, pivot - 1)
			(l2, r2) = (pivot + 1, x.j)
			if r1 - l1 + 1 > 0:
				heapq.heappush(heap, HeapNode(l1, r1))
			if r2 - l2 + 1 > 0:
				heapq.heappush(heap, HeapNode(l2, r2))
		for o in out:
			print(o, end=' ')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = lambda s: self.buffer.write(s.encode()) if self.writable else None

	def read(self):
		if self.buffer.tell():
			return self.buffer.read().decode('ascii')
		return os.read(self._fd, os.fstat(self._fd).st_size).decode('ascii')

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline().decode('ascii')

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

def print(*args, sep=' ', end='\n', file=sys.stdout, flush=False):
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(end)
	if flush:
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.setrecursionlimit(10000)
main()


from collections import defaultdict, deque
import heapq, bisect, math, itertools, string, queue, copy, time
import sys
input = sys.stdin.readline
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def inpl_str():
	return list(input().split())
ans = []
t = inp()
for _ in range(t):
	n = inp()
	numbers = [(-n, 0)]
	i = 1
	tmp = [0] * n
	while i < n + 1:
		(length, left) = heapq.heappop(numbers)
		if length == 0:
			continue
		half = (-length - 1) // 2 + left
		tmp[half] = i
		heapq.heappush(numbers, (-(half - left), left))
		heapq.heappush(numbers, (half - left + 1 + length, half + 1))
		i += 1
	ans.append(tmp)
for i in ans:
	print(*i)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(str(i)[2:-1]) for i in input().rstrip()]
for _ in range(val()):
	n = val()
	l = [0] * (n + 10)
	he = []
	he.append([-n, 1, n])
	i = 1
	while he:
		(curr, start, end) = heappop(he)
		ind = end - start + 1
		if ind & 1:
			ind = (start + end) // 2
		else:
			ind = (start + end - 1) // 2
		l[ind] = i
		if ind - start:
			heappush(he, [start - ind, start, ind - 1])
		if end - ind:
			heappush(he, [ind - end, ind + 1, end])
		i += 1
	print(*l[1:n + 1])


import heapq
T = int(input())
d = 0

def BFS(l, r):
	global d
	d = 1
	Q = []
	heapq.heappush(Q, (-(r - l), l, r))
	arr = [0] * r
	while len(Q) > 0:
		(x, l, r) = heapq.heappop(Q)
		m = None
		if (r - l + 1) % 2 == 1:
			m = (l + r) // 2
			if m - 1 >= l:
				heapq.heappush(Q, (-(m - 1 - l), l, m - 1))
			if r >= m + 1:
				heapq.heappush(Q, (-(r - m - 1), m + 1, r))
		else:
			m = (l + r - 1) // 2
			if r >= m + 1:
				heapq.heappush(Q, (-(r - m - 1), m + 1, r))
			if m - 1 >= l:
				heapq.heappush(Q, (-(m - 1 - l), l, m - 1))
		arr[m - 1] = d
		d += 1
	return arr
for _ in range(T):
	n = int(input())
	print(*BFS(1, n))


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	action = 1
	res = [0] * n
	heap = [(-(n - 1), 0, n - 1)]
	while heap:
		(d, i, j) = heapq.heappop(heap)
		ind = (i + j) // 2
		res[ind] = action
		if i <= ind - 1:
			heapq.heappush(heap, (-(ind - 1 - i), i, ind - 1))
		if ind + 1 <= j:
			heapq.heappush(heap, (-(j - (ind + 1)), ind + 1, j))
		action += 1
	for i in range(n):
		print(res[i], end=' ')
	print()


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
from random import randint
import time

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def main():
	n = get_int()
	queue = [(-n, 0)]
	heapq.heapify(queue)
	ans = [0] * n
	i = 1

	def push(l, start):
		if l <= 0:
			return
		heapq.heappush(queue, (-l, start))
	while queue:
		(l, j) = heapq.heappop(queue)
		l = -l
		mid = j + (l - 1) // 2
		ans[mid] = i
		i += 1
		push(mid - j, j)
		push(j + l - mid - 1, mid + 1)
	print(*ans)
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	segments = [(-n, 0, n - 1)]
	heapify(segments)
	c = 1
	a = [0] * n
	while segments != []:
		(length, l, r) = heappop(segments)
		m = (l + r) // 2
		a[m] = c
		c += 1
		length *= -1
		ll = m - 1 - l + 1
		rl = r - m - 1 + 1
		if m - 1 >= l:
			heappush(segments, (-ll, l, m - 1))
		if r >= m + 1:
			heappush(segments, (-rl, m + 1, r))
	print(*a)


import re

def find_all(arr, sub):
	a = []
	for county in range(len(arr) - sub + 1):
		if arr[county:county + sub] == [0] * sub:
			a.append(county)
	return a

def solve(arr, n):
	count = 1
	while count <= n:
		l0 = 0
		current = 0
		indexes = []
		for i in range(n):
			if arr[i] == 0:
				current += 1
				if i == n - 1:
					if current > l0:
						l0 = current
						indexes = [i - l0 + 1]
					elif current == l0:
						indexes.append(i - l0 + 1)
					else:
						pass
			else:
				if current > l0:
					l0 = current
					indexes = [i - l0]
				elif current == l0:
					indexes.append(i - l0)
				else:
					pass
				current = 0
		for i in indexes:
			if count > n:
				break
			if i + l0 % 2 == 0:
				arr[(i + (i + l0 - 1) - 1) // 2] = count
			else:
				arr[(i + (i + l0 - 1)) // 2] = count
			count += 1
	return arr
for t in range(int(input())):
	n = int(input())
	arr = [0 for _ in range(n)]
	print(*solve(arr, n))


from sys import stdout, stdin
from heapq import *
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

class Data:

	def __init__(self, val):
		self.val = val

	def __lt__(self, other):
		return self.val[1] - self.val[0] + 1 > other.val[1] - other.val[0] + 1 or (self.val[1] - self.val[0] + 1 == other.val[1] - other.val[0] + 1 and self.val[0] < other.val[0])
for t in range(int(input())):
	n = int(input())
	a = [0 for i in range(n)]
	q = [Data([1, n])]
	heapify(q)
	i = 1
	while q:
		(x, y) = heappop(q).val
		if (y - x + 1) % 2 == 1:
			a[(y + x) // 2 - 1] = i
			if (y + x) // 2 - 1 >= x:
				heappush(q, Data([x, (y + x) // 2 - 1]))
			if (y + x) // 2 + 1 <= y:
				heappush(q, Data([(y + x) // 2 + 1, y]))
		else:
			a[(y + x - 1) // 2 - 1] = i
			if (y + x - 1) // 2 - 1 >= x:
				heappush(q, Data([x, (y + x - 1) // 2 - 1]))
			if (y + x - 1) // 2 + 1 <= y:
				heappush(q, Data([(y + x - 1) // 2 + 1, y]))
		i += 1
	print(*a)


import heapq

def tuplmk(a, b):
	return (a - 1 - b, a, b)
t = int(input())
for pset in range(t):
	n = int(input())
	h = []
	ans = [0 for i in range(n)]
	heapq.heappush(h, tuplmk(1, n))
	for el in range(1, n + 1):
		seq = heapq.heappop(h)
		ind = (seq[1] + seq[2]) // 2
		ans[ind - 1] = el
		heapq.heappush(h, tuplmk(seq[1], ind - 1))
		heapq.heappush(h, tuplmk(ind + 1, seq[2]))
	print(' '.join([str(i) for i in ans]))


import heapq
from heapq import heappop, heappush, heapify

def main():
	for t in range(int(input())):
		n = int(input())
		heap = []
		a = [0] * n
		c = 0
		heapq.heappush(heap, (-n, 0, n - 1))
		for i in range(n):
			y = heapq.heappop(heap)
			l = y[1]
			r = y[2]
			mid = (l + r) // 2
			len = y[0]
			if l > r:
				continue
			c += 1
			a[mid] = c
			heapq.heappush(heap, (-1 * (mid - l + 1), l, mid - 1))
			heapq.heappush(heap, (-1 * (r - mid + 1), mid + 1, r))
		for i in a:
			print(i, end=' ')
		print()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from heapq import *
for _ in range(int(input())):
	n = int(input())
	A = [0] * n
	Q = [(-n, 0)]
	num = 1

	def push(l, start):
		if l <= 0:
			return
		heappush(Q, (-l, start))
	while Q:
		(l, i) = heappop(Q)
		l = -l
		mid = i + (l - 1) // 2
		A[mid] = num
		h = l // 2
		num += 1
		push(mid - i, i)
		push(i + l - mid - 1, mid + 1)
	print(*A)


from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max
tc = int(input())
for _ in range(tc):
	n = int(input())
	a = [0] * n
	z = [[-n, 0]]
	heapify(z)
	i = 0
	for i in range(1, n + 1):
		(le, l) = heappop(z)
		r = -le + l - 1
		m = (l + r) // 2
		a[m] = i
		heappush(z, [-(m - l), l])
		heappush(z, [-(r - m), m + 1])
	print(*a)


from heapq import heappush, heappop

def readStr():
	return input()

def readInts():
	return list(map(int, readStr().split(' ')))

def main(n):
	a = [0 for i in range(n)]
	s = []
	heappush(s, (-n, 0))
	for i in range(n):
		(l, j) = heappop(s)
		k = j + -l - 1
		t = (j + k) // 2
		a[t] = i + 1
		if t > j:
			heappush(s, (-(t - j), j))
		if k > t:
			heappush(s, (-(k - t), t + 1))
	return a
(t,) = readInts()
for _ in range(t):
	(n,) = readInts()
	a = main(n)
	print(' '.join(map(str, a)))


from heapq import *
for _ in range(int(input())):
	n = int(input())
	ans = [0 for i in range(n)]
	h = [[-n, 0, n - 1]]
	k = 1
	while h:
		(c, i, j) = heappop(h)
		mid = i + (j - i) // 2
		ans[mid] = k
		k += 1
		if mid > i:
			heappush(h, [i - mid, i, mid - 1])
		if mid < j:
			heappush(h, [mid - j, mid + 1, j])
	print(*ans, sep=' ')


import io
import os
from collections import Counter, defaultdict, deque
from heapq import heappush, heappop

def solve(N):
	out = [None] * N
	heap = [(-N, 0, N)]
	i = 1
	while heap:
		(negLength, l, r) = heappop(heap)
		mid = (l + r - 1) // 2
		out[mid] = i
		i += 1
		if mid - l > 0:
			heappush(heap, (-(mid - l), l, mid))
		if r - mid - 1 > 0:
			heappush(heap, (-(r - mid - 1), mid + 1, r))
	return ' '.join(map(str, out))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	ans = solve(N)
	print(ans)


import heapq

def find_array(n):
	(lo, hi) = (0, n - 1)
	heap = [(-(hi - lo + 1), lo, hi)]
	pos = []
	while heap:
		u = heapq.heappop(heap)
		(lo, hi) = (u[1], u[2])
		mid = lo + hi >> 1
		pos.append(mid)
		(alo, ahi) = (lo, mid - 1)
		(blo, bhi) = (mid + 1, hi)
		(len_a, len_b) = (ahi - alo + 1, bhi - blo + 1)
		if len_a > 0:
			heapq.heappush(heap, (-len_a, alo, ahi))
		if len_b > 0:
			heapq.heappush(heap, (-len_b, blo, bhi))
	res = [0] * len(pos)
	for i in range(len(pos)):
		res[pos[i]] = i + 1
	return res

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		arr = find_array(n)
		for j in range(len(arr)):
			if j == len(arr) - 1:
				print(arr[j])
			else:
				print(arr[j], end=' ')
main()


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	ans = [0] * n
	hq = [(-n, 0)]
	i = 1
	while hq:
		(p, l) = heapq.heappop(hq)
		p = -p
		if p == 0:
			continue
		r = l + p - 1
		ans[(l + r) // 2] = i
		i += 1
		if p % 2:
			heapq.heappush(hq, (-(p // 2), l))
			heapq.heappush(hq, (-(p // 2), (l + r) // 2 + 1))
		else:
			heapq.heappush(hq, (-(p // 2 - 1), l))
			heapq.heappush(hq, (-(p // 2), (l + r) // 2 + 1))
	print(*ans)


import heapq
for _ in range(int(input())):
	n = int(input())
	heap = [(n, (0, n - 1))]
	result = [0] * n
	number = 1
	while heap:
		(length, (l, r)) = heapq.heappop(heap)
		mid = (l + r) // 2
		result[mid] = number
		number += 1
		if mid - l >= 1:
			heapq.heappush(heap, (-(mid - l), (l, mid - 1)))
		if r - mid >= 1:
			heapq.heappush(heap, (-(r - mid), (mid + 1, r)))
	for i in result:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	count = 1
	ar = [[0, n]]
	ans = [0] * n
	flag = True
	while count != n + 1 and flag:
		flag = False
		tem = []
		temeven = []
		for i in ar:
			if i[1] % 2 != 0:
				le = i[1] // 2
				if le == 0:
					tem.append([i[0], 1])
				else:
					flag = True
					ans[i[0] + le] = count
					count += 1
					if le % 2 == 0:
						temeven.append([i[0], i[1] // 2])
						temeven.append([i[0] + le + 1, i[1] // 2])
					else:
						tem.append([i[0], i[1] // 2])
						tem.append([i[0] + le + 1, i[1] // 2])
			else:
				le = i[1] // 2
				if le == 1:
					ans[i[0]] = count
					count += 1
					tem.append([i[0] + 1, 1])
				else:
					flag = True
					ans[i[0] + le - 1] = count
					count += 1
					if le % 2 == 0:
						temeven.append([i[0] + le, i[1] // 2])
						tem.append([i[0], i[1] // 2 - 1])
					else:
						tem.append([i[0] + le, i[1] // 2])
						temeven.append([i[0], i[1] // 2 - 1])
		tem.sort()
		temeven.sort()
		if not tem or not temeven:
			ar = (tem + temeven).copy()
		elif tem[0][1] > temeven[0][1]:
			ar = (tem + temeven).copy()
		else:
			ar = (temeven + tem).copy()
	for i in ar:
		ans[i[0]] = count
		count += 1
	print(*ans)


import heapq

def solve(n):
	a = [0] * n
	q = [(-n, 0, n - 1)]
	for i in range(n):
		(_, l, r) = heapq.heappop(q)
		m = (l + r) // 2
		a[m] = i + 1
		heapq.heappush(q, (-(m - l), l, m - 1))
		heapq.heappush(q, (-(r - m), m + 1, r))
	return ' '.join(map(str, a))

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		print(solve(n))
main()


from heapq import *

def push(l, start):
	if l > 0:
		heappush(hp, (-l, start))
for t in range(int(input())):
	n = int(input())
	a = [0] * n
	k = 1
	hp = [(-n, 0)]
	while hp:
		(l, i) = heappop(hp)
		l = -l
		m = i + (l - 1) // 2
		a[m] = k
		k += 1
		push(m - i, i)
		push(i + l - m - 1, m + 1)
	print(*a)


import random
import math
import sys
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
yes = lambda : print('Yes')
no = lambda : print('No')
I = lambda : list(input())
J = lambda x: ''.join(x)
II = lambda : int(input())
SI = lambda : input()
t = II()
for q in range(t):
	n = II()
	a = [0] * n
	temp = 1
	for i in range(n):
		start = 0
		end = 0
		maxS = 0
		maxE = 0
		l = []
		for j in range(n):
			if a[j] != 0:
				if end - start > maxE - maxS:
					maxS = start
					maxE = end
					l = []
				elif end - start == maxE - maxS:
					l.append((start + end - 1) // 2)
				start = end + 1
				end = end + 1
			else:
				end += 1
		if end - start > maxE - maxS:
			maxS = start
			maxE = end
			l = []
		elif end - start == maxE - maxS:
			l.append((start + end - 1) // 2)
		if maxS == maxE:
			break
		a[(maxS + maxE - 1) // 2] = temp
		temp += 1
		for j in l:
			a[j] = temp
			temp += 1
	for i in range(n):
		if a[i] == 0:
			a[i] = temp
			temp += 1
	print(*a)


import sys, heapq
input = sys.stdin.buffer.readline
T = int(input())
big = 300000
dg = 10 ** 6

def f(p, q):
	return (big - p) * dg + q
for _ in range(T):
	n = int(input())
	tank = [f(n, 0)]
	res = [0] * n
	task = 1
	while tank:
		val = heapq.heappop(tank)
		le = big - val // dg
		start = val % dg
		if le % 2 == 0:
			res[start + le // 2 - 1] = task
			if le == 2:
				heapq.heappush(tank, f(1, start + 1))
			else:
				heapq.heappush(tank, f(le // 2 - 1, start))
				heapq.heappush(tank, f(le // 2, start + le // 2))
		else:
			res[start + le // 2] = task
			if le != 1:
				heapq.heappush(tank, f(le // 2, start))
				heapq.heappush(tank, f(le // 2, start + le // 2 + 1))
		task += 1
	print(*res)


import sys
input = sys.stdin.readline
import heapq
for _ in range(int(input())):
	n = int(input())
	arr = [0] * (n + 1)
	queue = []
	heapq.heappush(queue, [-n, 1, n])
	operation = 0
	while queue:
		(size, l, r) = heapq.heappop(queue)
		operation += 1
		mid = l + (r - l) // 2
		arr[mid] = operation
		if l <= mid - 1:
			new_size = mid - l
			heapq.heappush(queue, [-new_size, l, mid - 1])
		if mid + 1 <= r:
			new_size = r - mid
			heapq.heappush(queue, [-new_size, mid + 1, r])
	print(*arr[1:])


def bubble_sort(c):
	n = len(c)
	for i in range(n):
		already_sorted = True
		for j in range(n - i - 1):
			if c[j][0] < c[j + 1][0]:
				(c[j][0], c[j + 1][0]) = (c[j + 1][0], c[j][0])
				already_sorted = False
			if c[j][0] == c[j + 1][0]:
				if c[j][1] > c[j + 1][1]:
					(c[j][1], c[j + 1][1]) = (c[j + 1][1], c[j][1])
		if already_sorted:
			break
	return c

def fun(l, r):
	if l > r:
		return
	m = (l + r) // 2
	c.append([l - r, m])
	fun(l, m - 1)
	fun(m + 1, r)
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [0 for i in range(n)]
	c = []
	fun(0, n - 1)
	c.sort()
	for i in range(1, n + 1):
		idi = c[i - 1][1]
		a[idi] = i
	print(*a)


import heapq
from sys import stdin
from sys import stdout

def gen(l, r, n):
	return (n - (r - l + 1), (l, r))

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		a = [0] * n
		k = 1
		q = []
		heapq.heappush(q, gen(0, n - 1, n))
		while k <= n:
			xyz = heapq.heappop(q)
			(left, right) = xyz[1]
			med = (left + right) // 2
			a[med] = k
			if left <= med - 1:
				heapq.heappush(q, gen(left, med - 1, n))
			if med + 1 <= right:
				heapq.heappush(q, gen(med + 1, right, n))
			k += 1
		stdout.write(' '.join(map(str, a)) + '\n')
main()


from sys import stdin
import heapq
t = int(stdin.readline())
for _ in range(t):
	N = int(stdin.readline())
	pattern = [0 for _ in range(N + 1)]
	pattern_heap = [-N]
	pattern_hashmap = {N: [(1, N)]}
	for i in range(1, N + 1):
		max_zeros = pattern_heap[0] * -1
		(l, r) = heapq.heappop(pattern_hashmap[max_zeros])
		mid = (l + r) // 2
		pattern[mid] = i
		if l < mid:
			if mid - l in pattern_hashmap:
				heapq.heappush(pattern_hashmap[mid - l], (l, mid - 1))
			else:
				pattern_hashmap[mid - l] = [(l, mid - 1)]
				heapq.heappush(pattern_heap, -(mid - l))
		if mid < r:
			if r - mid in pattern_hashmap:
				heapq.heappush(pattern_hashmap[r - mid], (mid + 1, r))
			else:
				pattern_hashmap[r - mid] = [(mid + 1, r)]
				heapq.heappush(pattern_heap, -(r - mid))
		if len(pattern_hashmap[max_zeros]) == 0:
			heapq.heappop(pattern_heap)
			del pattern_hashmap[max_zeros]
	for var in pattern[1:]:
		print(var, end=' ')
	print()


from heapq import heapreplace, heapify, heappop
from bisect import insort

def merge(iterables):
	entries = []
	for (id, it) in enumerate(map(iter, iterables)):
		try:
			entries.append([next(it), id, it])
		except StopIteration:
			pass
	heapify(entries)
	while entries:
		(value, _, it) = entry = entries[0]
		yield value
		try:
			entry[0] = next(it)
			heapreplace(entries, entry)
		except StopIteration:
			heappop(entries)

def combine(a, b):
	(a, b) = (iter(a), iter(b))
	(x, y) = (next(a, none), next(b, none))
	while x or y:
		if x is none:
			yield y
			y = next(b, none)
		elif y is none:
			yield x
			x = next(a, none)
		elif x < y:
			yield x
			x = next(a, none)
		else:
			yield y
			y = next(b, none)

def construct(n):
	a = [0] * n
	queue = [-1, n]
	index = []
	g = iter(range(1, n + 1))
	i = 0
	while len(queue) - 2 != n:
		(level, prev) = ([], queue[0])
		for y in queue:
			x = prev
			if x + 1 < y:
				i = (x + y) // 2
				index.append((x - y, i))
				level.append(i)
			prev = y
		queue = list(merge([iter(queue), iter(level)]))
	for (_, i) in sorted(index):
		a[i] = next(g)
	return a

def solve():
	n = int(input())
	print(*construct(n))
for _ in range(int(input())):
	solve()


import heapq
T = int(input())
for t in range(T):
	n = int(input())
	ans = [0] * (n + 1)
	q = []
	heapq.heappush(q, [1 - n, 1, n])
	i = 1
	while len(q) > 0:
		(_, l, r) = heapq.heappop(q)
		j = 0
		if (r - l + 1) % 2 == 1:
			j = (l + r) // 2
		else:
			j = (l + r - 1) // 2
		ans[j] = i
		i += 1
		if j + 1 <= r:
			heapq.heappush(q, [j + 1 - r, j + 1, r])
		if l <= j - 1:
			heapq.heappush(q, [l - j + 1, l, j - 1])
	print(' '.join([str(v) for v in ans[1:]]))


import heapq

def solve(n):
	a = [0] * n
	zero_segments = [(-n, 0, n - 1)]
	for i in range(1, n + 1):
		(_, l, r) = heapq.heappop(zero_segments)
		if (r - l + 1) % 2 != 0:
			pivot = (l + r) // 2
		else:
			pivot = (l + r - 1) // 2
		a[pivot] = i
		if pivot > 0 and l != pivot:
			heapq.heappush(zero_segments, (l - pivot, l, pivot - 1))
		if pivot < n - 1 and r != pivot:
			heapq.heappush(zero_segments, (pivot - r, pivot + 1, r))
	assert not zero_segments
	return ' '.join(map(str, a))

def main():
	T = int(input())
	for _ in range(T):
		n = int(input())
		print(solve(n))
main()


from heapq import heapify, heappop, heappush

def solve(n):
	a = [0] * n
	num = 1
	pq = [(-n, (0, n - 1))]
	heapify(pq)
	while pq:
		(ln, (left, right)) = heappop(pq)
		if (right - left + 1) % 2 == 1:
			mid = (left + right) // 2
			a[mid] = num
		else:
			mid = (left + right - 1) // 2
			a[mid] = num
		(nl1, nr1) = (left, mid - 1)
		(nl2, nr2) = (mid + 1, right)
		if nl1 <= nr1:
			heappush(pq, (-(nr1 - nl1 + 1), (nl1, nr1)))
		if nl2 <= nr2:
			heappush(pq, (-(nr2 - nl2 + 1), (nl2, nr2)))
		num += 1
	return a
for _ in range(int(input())):
	n = int(input())
	print(*solve(n))


from heapq import *

def fun(n):
	dp = [0 for i in range(n + 1)]
	heap = [(n, (1, n))]
	heapify(heap)
	count = 1
	while heap:
		(size, (l, r)) = heappop(heap)
		if (r - l + 1) % 2:
			mid = (l + r) // 2
			dp[mid] = count
			count += 1
			if r - mid > 0:
				heappush(heap, (mid - r, (mid + 1, r)))
			if mid - l > 0:
				heappush(heap, (l - mid, (l, mid - 1)))
		else:
			mid = (l + r - 1) // 2
			dp[mid] = count
			count += 1
			if r - mid > 0:
				heappush(heap, (mid - r, (mid + 1, r)))
			if mid - l > 0:
				heappush(heap, (l - mid, (l, mid - 1)))
	return dp
t = int(input())
for i in range(t):
	n = int(input())
	dp = fun(n)
	print(*dp[1:])


import sys
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
import heapq
from heapq import heappop, heappush, heapify
for t in range(int(stdin.readline())):
	n = int(stdin.readline())
	heap = []
	a = [0] * n
	c = 0
	heapq.heappush(heap, (-n, 0, n - 1))
	for i in range(n):
		y = heapq.heappop(heap)
		l = y[1]
		r = y[2]
		mid = (l + r) // 2
		len = y[0]
		if l > r:
			continue
		c += 1
		a[mid] = c
		heapq.heappush(heap, (-1 * (mid - l + 1), l, mid - 1))
		heapq.heappush(heap, (-1 * (r - mid + 1), mid + 1, r))
	for i in a:
		stdout.write(str(i) + ' ')
	print()


import heapq as hq
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * n
	maxlen = []
	hq.heappush(maxlen, -n)
	left = {}
	left[n] = []
	hq.heappush(left[n], 0)
	l = 0
	r = n - 1
	count = 1
	while count <= n:
		length = -hq.heappop(maxlen)
		l = hq.heappop(left[length])
		r = length + l - 1
		p = (l + r) // 2
		arr[p] = count
		count += 1
		r = p - 1
		if l <= p - 1 and p != 0:
			hq.heappush(maxlen, -(r - l + 1))
			if r - l + 1 in left:
				hq.heappush(left[r - l + 1], l)
			else:
				left[r - l + 1] = []
				hq.heappush(left[r - l + 1], l)
		r = length + l - 1
		l = p + 1
		if p + 1 <= r and p != n - 1:
			hq.heappush(maxlen, -(r - l + 1))
			if r - l + 1 in left:
				hq.heappush(left[r - l + 1], l)
			else:
				left[r - l + 1] = []
				hq.heappush(left[r - l + 1], l)
	for i in arr:
		print(i, end=' ')
	print()


from heapq import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	q = []
	heappush(q, (-n, 0, n - 1))
	arr = [0] * n
	for i in range(n):
		p = heappop(q)
		(l, r) = (p[1], p[2])
		mid = (l + r) // 2
		arr[mid] = i + 1
		if mid - l > 0:
			heappush(q, (-mid + l, l, mid - 1))
		if r - mid > 0:
			heappush(q, (-r + mid, mid + 1, r))
	print(*arr)


def f(l, r):
	if l > r:
		return
	mid = (l + r) // 2
	a[mid] = [l - r, mid]
	f(l, mid - 1)
	f(mid + 1, r)
t = int(input())
for _ in range(t):
	n = int(input())
	a = b = [0] * (n + 1)
	f(1, n)
	i = 1
	a.pop(0)
	a = sorted(a)
	for j in a:
		b[j[1] - 1] = i
		i += 1
	print(*b)


import heapq as hq
for _ in range(int(input())):
	n = int(input())
	a = [0] * (n + 1)
	arr = [(-1 * n, 1, n)]
	cnt = 1
	hq.heapify(arr)
	while len(arr) != 0:
		(s, l, r) = hq.heappop(arr)
		mid = (l + r) // 2
		a[mid] = cnt
		cnt = cnt + 1
		if mid - 1 >= l:
			hq.heappush(arr, [-1 * (mid - l), l, mid - 1])
		if mid + 1 <= r:
			hq.heappush(arr, [-1 * (r - mid), mid + 1, r])
	a.pop(0)
	print(*a)


import sys
input = lambda : sys.stdin.readline().rstrip()
from heapq import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [[-n, 0, n - 1]]
	ans = [0] * n
	for i in range(n):
		p = heappop(a)
		if p[0] & 1:
			l = (p[0] + 1) // 2
			if l:
				heappush(a, [l, p[1], p[1] - l - 1])
			if l:
				heappush(a, [l, p[1] - l + 1, p[2]])
			ans[p[1] - l] = i + 1
		else:
			s = p[0] // 2 + 1
			e = p[0] // 2
			if s:
				heappush(a, [s, p[1], p[1] - s - 1])
			if e:
				heappush(a, [e, p[1] - s + 1, p[2]])
			ans[p[1] - s] = i + 1
	print(*ans)


import heapq
t = int(input())

def solve(n):
	arr = [0 for _ in range(n)]
	heap = [(-n, 0, n - 1)]
	heapq.heapify(heap)
	i = 1
	while len(heap) > 0:
		(numz, lo, hi) = heapq.heappop(heap)
		numz = -numz
		if lo > hi:
			continue
		mid = (lo + hi) // 2
		arr[mid] = i
		i += 1
		left = 0
		right = 0
		if (hi - lo) % 2 == 0:
			left = numz // 2
			right = numz // 2
		else:
			left = numz // 2 - 1
			right = numz // 2
		if lo <= mid - 1:
			heapq.heappush(heap, (-left, lo, mid - 1))
		if mid + 1 <= hi:
			heapq.heappush(heap, (-right, mid + 1, hi))
	return ' '.join(list(map(str, arr)))
for _ in range(t):
	n = int(input())
	print(solve(n))


from sys import stdout, stdin
(_input, _print) = (stdin.buffer.readline, stdout.write)
(_range, _int) = (range, int)

class Elem:
	__slots__ = ['v', 'l', 'r']

	def __init__(self, v, l, r):
		(self.v, self.l, self.r) = (v, l, r)

	def __lt__(self, other):
		if self.v > other.v:
			return True
		elif self.v == other.v and self.l < other.l:
			return True
		else:
			return False

	def get(self):
		return (self.v, self.l, self.r)
from heapq import heappush, heappop

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		a = [0] * n
		el = Elem(n - 1, 1, n)
		h = [el]
		for i in _range(n):
			el = heappop(h)
			(v, l, r) = el.get()
			if (r - l) % 2 == 0:
				temp = (r + l) // 2
			else:
				temp = (r + l - 1) // 2
			a[temp - 1] = i + 1
			if temp > l:
				el = Elem(temp - 1 - l, l, temp - 1)
				heappush(h, el)
			if temp < r:
				el = Elem(r - (temp + 1), temp + 1, r)
				heappush(h, el)
		print(*a)
solution()


from heapq import *
t = int(input())
for u in range(t):
	n = int(input())
	h = []
	a = [0] * n
	heappush(h, (n, 0, n - 1))
	ln = 1
	i = 1
	while ln > 0:
		(now0, now1, now2) = heappop(h)
		ln -= 1
		if now1 == now2:
			a[now1] = i
		else:
			a[now1 + (now2 - now1) // 2] = i
			if now2 - now1 == 1:
				heappush(h, (n - 1, now2, now2))
				ln += 1
			else:
				if 0 <= now1 + (now2 - now1) // 2 - 1:
					nl = n - (now1 + (now2 - now1) // 2 - 1 - now1 + 1)
					heappush(h, (nl, now1, now1 + (now2 - now1) // 2 - 1))
					ln += 1
				if now1 + (now2 - now1) // 2 + 1 < n:
					nl = n - (now2 - (now1 + (now2 - now1) // 2 + 1) + 1)
					heappush(h, (nl, now1 + (now2 - now1) // 2 + 1, now2))
					ln += 1
		i += 1
	print(*a)


from heapq import *
from sys import *
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	h = []
	a = [0] * n
	l = 0
	r = n - 1
	heappush(h, (l - r, l, r))
	cn = 1
	while len(h) > 0:
		(d, l, r) = heappop(h)
		md = (l + r) // 2
		a[md] = cn
		l1 = l
		r1 = md - 1
		l2 = md + 1
		r2 = r
		if l1 <= r1:
			heappush(h, (l1 - r1, l1, r1))
		if l2 <= r2:
			heappush(h, (l2 - r2, l2, r2))
		cn += 1
	for i in a:
		stdout.write(str(i) + ' ')
	stdout.write('\n')


import sys

def answer(n):
	ans = [0 for _ in range(n)]
	stack = [(0, n - 1)]
	t_ans = [(0, 0) for _ in range(n)]
	while len(stack) > 0:
		tup = stack.pop()
		l = tup[0]
		r = tup[1]
		mid = (l + r) // 2
		w = -(r - l + 1)
		t_ans[mid] = (w, mid)
		if mid - 1 >= l:
			stack.append((l, mid - 1))
		if r >= mid + 1:
			stack.append((mid + 1, r))
	t_ans.sort()
	for i in range(n):
		pos = t_ans[i][1]
		ans[pos] = i + 1
	return ans

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		print(*answer(n))
		t -= 1
	return
main()


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
from heapq import heappush, heappop

def solve(n):
	arr = [0] * n
	h = []
	if n > 1:
		heappush(h, (n - 1, 0, n - 1))
	i = 1
	while len(h) > 0:
		curr_range = heappop(h)[1:]
		curr = sum(curr_range)
		mid = curr // 2
		arr[mid] = i
		i += 1
		left = (curr_range[0], mid - 1)
		right = (mid + 1, curr_range[1])
		if curr % 2 == 0:
			if left[1] - left[0] > 0:
				heappush(h, (left[0] - left[1], left[0], left[1]))
			if right[1] - right[0] > 0:
				heappush(h, (right[0] - right[1], right[0], right[1]))
		else:
			if right[1] - right[0] > 0:
				heappush(h, (right[0] - right[1], right[0], right[1]))
			if left[1] - left[0] > 0:
				heappush(h, (left[0] - left[1], left[0], left[1]))
	for j in range(n):
		if arr[j] == 0:
			arr[j] = i
			i += 1
	return arr
for i in range(int_in()):
	n = int_in()
	arr_out(solve(n))


import operator
t = int(input())

def solve(l, r):
	if r < l:
		return
	mid = (l + r) // 2
	temp[mid] = (r - l, mid)
	solve(l, mid - 1)
	solve(mid + 1, r)
for i in range(t):
	n = int(input())
	temp = [None for j in range(n)]
	output = [None for j in range(n)]
	solve(0, n - 1)
	temp.sort(key=lambda ts: (-ts[0], ts[1]))
	for k in range(len(temp)):
		output[temp[k][1]] = k + 1
	for l in range(len(output)):
		print(output[l], end=' ')
	print('')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	answer = [0] * n
	arr = [(-n, 0, n - 1)]
	heapify(arr)
	i = 1
	while arr:
		temp = heappop(arr)
		mid = (temp[1] + temp[2]) // 2
		if mid >= n:
			mid = n - 1
		answer[mid] = i
		i += 1
		if temp[1] <= mid - 1:
			heappush(arr, (temp[1] - mid, temp[1], mid - 1))
		if temp[2] >= mid + 1:
			heappush(arr, (mid - temp[2], mid + 1, temp[2]))
	out(*answer)


import sys
from collections import *
from heapq import *
import math
import bisect

def input():
	return sys.stdin.readline()

def diff(r):
	return (r[0] - r[1], r)
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	h = [diff((0, n - 1))]
	heapify(h)
	i = 1
	while h:
		(d, r) = heappop(h)
		if r[1] - r[0] + 1 & 1:
			mid = (r[0] + r[1]) // 2
			if r[1] - r[0] > 1:
				heappush(h, diff((r[0], mid - 1)))
				heappush(h, diff((mid + 1, r[1])))
		else:
			mid = (r[0] + r[1] - 1) // 2
			heappush(h, diff((mid + 1, r[1])))
			if r[1] - r[0] > 2:
				heappush(h, diff((r[0], mid - 1)))
		a[mid] = i
		i += 1
	print(*a)


import collections
import heapq

def solve(n):
	arr = [0 for _ in range(n + 1)]
	pq = []
	heapq.heappush(pq, (-n, 1, n))
	for i in range(1, n + 1):
		(maxLen, l, r) = heapq.heappop(pq)
		if r - l + 1 & 1:
			mid = (l + r) // 2
		else:
			mid = (l + r - 1) // 2
		arr[mid] = i
		(newLOne, newROne) = (l, mid - 1)
		(newLTwo, newRTwo) = (mid + 1, r)
		if newROne - newLOne + 1 > 0:
			heapq.heappush(pq, (-(newROne - newLOne + 1), newLOne, newROne))
		if newRTwo - newLTwo + 1 > 0:
			heapq.heappush(pq, (-(newRTwo - newLTwo + 1), newLTwo, newRTwo))
	return ' '.join(map(str, arr[1:]))
t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	print(solve(n))


def recurse(start, end, log):
	if start > end:
		return
	else:
		mid = (start + end) // 2
		log.append((start, mid, end))
		recurse(mid + 1, end, log)
		recurse(start, mid - 1, log)
for _ in range(int(input())):
	size = int(input())
	memo = []
	recurse(0, size - 1, memo)
	memo = sorted(memo, key=lambda x: (x[2] - x[0], -x[0]), reverse=True)
	ans = [0] * size
	for i in range(len(memo)):
		ans[memo[i][1]] = i + 1
	print(*ans)


import sys
import heapq
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	h = [(-n, (0, n - 1))]
	i = 1
	while i <= n:
		(s, (l, r)) = heapq.heappop(h)
		mid = (l + r) // 2
		a[mid] = i
		heapq.heappush(h, (-(mid - 1 - l), (l, mid - 1)))
		heapq.heappush(h, (-(r - (mid + 1)), (mid + 1, r)))
		i += 1
	print(*a)


from heapq import heappush, heappop

def cal(l, r):
	n = r - l + 1
	if n % 2 == 1:
		return (r + l) // 2
	return (r + l - 1) // 2
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	ran = []
	heappush(ran, (-n, 1, n))
	c = 1
	while len(ran) > 0:
		v = ran[0]
		heappop(ran)
		x = cal(v[1], v[2]) - 1
		a[x] = c
		c += 1
		if v[1] < v[2]:
			heappush(ran, (-(x - v[1] + 1), v[1], x))
			heappush(ran, (-(v[2] - x - 1), x + 2, v[2]))
		if c == n + 1:
			break
	print(*a)


from collections import defaultdict as dd
import math
import sys
import heapq
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
q = nn()

def heap_place(lower, upper):
	if (upper - lower) % 2 == 1:
		p = (upper - lower) // 2 + lower
		out[p] = value
	else:
		p = (upper - lower) // 2 - 1 + lower
		out[p] = value
	if p > lower:
		heapq.heappush(h, (lower - p, lower, p))
	if upper > p + 1:
		heapq.heappush(h, (p + 1 - upper, p + 1, upper))
for _ in range(q):
	n = nn()
	out = [0] * n
	h = [(-n, 0, n)]
	value = 1
	while h:
		next = heapq.heappop(h)
		heap_place(next[1], next[2])
		value += 1
	print(*out)


tests = int(input())
for i in range(tests):
	n = int(input())
	answer = [1] * n
	line = [[1, n, 1]]
	result = []
	while n > 1:
		n = n // 2
		stack = []
		for j in range(len(line)):
			left = line[j][0]
			right = line[j][1]
			if right == left:
				stack.append([left, right, 0])
			elif (right + left) % 2 == 0:
				if (right + left) // 2 - left == n:
					stack.append([left, (left + right) // 2 - 1, 1])
					stack.append([(left + right) // 2 + 1, right, 1])
				else:
					stack.append([left, (left + right) // 2 - 1, 0])
					stack.append([(left + right) // 2 + 1, right, 0])
			else:
				stack.append([left, (left + right) // 2 - 1, 0])
				stack.append([(left + right) // 2 + 1, right, 1])
			if line[j][2] == 1:
				result.append((right + left) // 2)
		for j in range(len(line)):
			if line[j][2] == 0:
				left = line[j][0]
				right = line[j][1]
				if left != right:
					result.append((right + left) // 2)
		if n == 1:
			for j in range(len(stack)):
				if stack[j][0] == stack[j][1]:
					result.append(stack[j][0])
		line = stack
	for j in range(len(result)):
		answer[result[j] - 1] = j + 1
	for j in range(len(answer)):
		print(answer[j], end=' ')
	print()


import sys

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def rec(p, q):
	if p + 2 >= q:
		return
	c.append([-(int(ceil((p + q) / 2)) - p - 1), p, int(ceil((p + q) / 2)) - 1])
	c.append([-(q - int(ceil((p + q) / 2))), int(ceil((p + q) / 2)), q])
	rec(p, int(ceil((p + q) / 2) - 1))
	rec(int(ceil((p + q) / 2)), q)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = [0 for i in range(n)]
	c = [[-n, 0, n]]
	rec(0, n)
	c.sort()
	f = 0
	for i in range(len(c)):
		if c[i][1] == c[i][2] or c[i][0] == -1:
			continue
		a[int(ceil((c[i][1] + c[i][2]) / 2)) - 1] = f + 1
		f += 1
	f += 1
	for i in range(len(a)):
		if a[i] == 0:
			a[i] = f
			f += 1
	print(*a)


import heapq

def solve():
	n = int(input())
	cur = 1
	a = [0] * n
	q = []
	heapq.heappush(q, (-n, 0, n))
	while q:
		(_, l, r) = heapq.heappop(q)
		mid = (l + r - 1) // 2
		a[mid] = cur
		cur += 1
		if l < mid:
			heapq.heappush(q, (l - mid, l, mid))
		if mid + 1 < r:
			heapq.heappush(q, (mid + 1 - r, mid + 1, r))
	print(*a)
t = int(input())
for _ in range(t):
	solve()


from sys import stdin, stdout
import heapq
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	arr = [0] * n
	h = [(-n, 0)]
	cur = 1
	while h:
		(l, idx) = heapq.heappop(h)
		l = -l
		arr[idx + (l - 1) // 2] = cur
		cur += 1
		(l1, l2) = ((l - 1) // 2, l // 2)
		if l1 > 0:
			heapq.heappush(h, (-l1, idx))
		if l2 > 0:
			heapq.heappush(h, (-l2, idx + l1 + 1))
	stdout.write(' '.join(map(str, arr)) + '\n')


from heapq import *
for i in range(int(input())):
	n = int(input())
	q = [(1 - n, 1, n)]
	order = []
	ans = [0] * n
	count = 1
	while q:
		val = heappop(q)
		r = (val[1] + val[2]) // 2
		order.append(r)
		ans[r - 1] = count
		count += 1
		if val[2] - val[1] == 1:
			heappush(q, (0, val[2], val[2]))
			continue
		if val[2] > val[1]:
			heappush(q, (r + 1 - val[2], r + 1, val[2]))
			heappush(q, (val[1] - r + 1, val[1], r - 1))
	print(*ans)


import heapq
k = 1

def solve():
	global k
	n = int(input())
	a = [0] * n
	h = []
	heapq.heappush(h, [-(n - 1), 1, n])
	mid = (n + 1) // 2
	while heapq and k <= n:
		lis = heapq.heappop(h)
		l = lis[1]
		r = lis[2]
		mid = (l + r) // 2
		a[mid - 1] = k
		k += 1
		if l <= mid - 1:
			heapq.heappush(h, [-(mid - 1 - l), l, mid - 1])
		if mid + 1 <= r:
			heapq.heappush(h, [-(r - (mid + 1)), mid + 1, r])
	return a
for i in range(int(input())):
	k = 1
	i = 1
	print(*solve())


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	q = []
	lst = [0] * n
	heapq.heappush(q, (-n, 0, n - 1))
	counter = 1
	while q:
		(size, l, r) = heapq.heappop(q)
		mid = (l + r) // 2
		lst[mid] = counter
		counter += 1
		if mid - l != 0 or l <= mid - 1:
			heapq.heappush(q, (-(mid - l), l, mid - 1))
		if r - mid != 0 or mid + 1 <= r:
			heapq.heappush(q, (-(r - mid), mid + 1, r))
	print(*lst)


import sys
input = sys.stdin.readline

def construct(A, count, MAX):
	B = []
	NMAX = 0
	for (l, r) in A:
		if r - l + 1 == MAX:
			ANS[(r + l) // 2] = count
			count += 1
			if l <= (r + l) // 2 - 1:
				NMAX = max(NMAX, (r + l) // 2 - l)
				B.append((l, (r + l) // 2 - 1))
			if r >= (r + l) // 2 + 1:
				NMAX = max(NMAX, r - (r + l) // 2)
				B.append(((r + l) // 2 + 1, r))
		else:
			NMAX = max(NMAX, r - l + 1)
			B.append((l, r))
	if NMAX != 0:
		construct(B, count, NMAX)
t = int(input())
for tests in range(t):
	n = int(input())
	ANS = [0] * n
	construct([(0, n - 1)], 1, n)
	print(*ANS)


import heapq
from heapq import heappop, heappush, heapify
for t in range(int(input())):
	n = int(input())
	heap = []
	a = [0] * n
	c = 0
	heapq.heappush(heap, (-n, 0, n - 1))
	for i in range(n):
		y = heapq.heappop(heap)
		l = y[1]
		r = y[2]
		j = (l + r) // 2
		c += 1
		a[j] = c
		if j + 1 <= r:
			heappush(heap, (-(r - (j + 1) + 1), j + 1, r))
		if l <= j - 1:
			heappush(heap, (-(j - 1 - l + 1), l, j - 1))
	print(*a[0:])


from collections import *
from bisect import *
from math import *
from heapq import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [0] * n
	he = []
	he1 = []
	he1 = [[1, n]]
	he1 = deque(he1)
	for i in range(n):
		l1 = he1[0][0]
		r1 = he1[0][1]
		he1.popleft()
		aff = (l1 + r1) // 2
		he.append([r1 - l1 + 1, -((l1 + r1) // 2)])
		if l1 != aff:
			he1.append([l1, aff - 1])
		if r1 != aff:
			he1.append([aff + 1, r1])
	he.sort(reverse=True)
	for i in range(n):
		a[abs(he[i][1]) - 1] = i + 1
	print(*a)


from heapq import heapify, heappush, heappop
for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	hp = []
	heapify(hp)
	heappush(hp, (-1 * n, 1, n))
	i = 1
	while hp:
		(l, a, b) = heappop(hp)
		ind = 0
		if a == b:
			ans[a - 1] = str(i)
			i += 1
			continue
		if (b - a + 1) % 2 == 0:
			ind = (a + b - 1) // 2
		else:
			ind = (a + b) // 2
		ans[ind - 1] = str(i)
		if ind != a:
			heappush(hp, (a - ind, a, ind - 1))
		heappush(hp, (ind - b, ind + 1, b))
		i += 1
	print(' '.join(ans))
	print()


import sys
import heapq
input = sys.stdin.readline
tc = int(input())

def push(y, a, b, c):
	if a:
		heapq.heappush(y, (a, b, c))

def do4(k):
	x = [0] * k
	y = [(-k, 0, k)]
	for i in range(1, 1 + k):
		(d, l, r) = heapq.heappop(y)
		m = (l + r - 1) // 2
		x[m] = i
		push(y, l - m, l, m)
		push(y, m + 1 - r, m + 1, r)
	print(*x)
for _ in range(tc):
	do4(int(input()))


import sys
input = sys.stdin.readline

def dp(l, r):
	if l <= r:
		m = (l + r) // 2
		vals[m] = [-(r - l + 1), m]
		dp(l, m - 1)
		dp(m + 1, r)
for _ in range(int(input())):
	vals = [0 for i in range(int(input()))]
	ans = [0 for i in range(len(vals))]
	dp(0, len(vals) - 1)
	vals.sort()
	for i in range(len(vals)):
		ans[vals[i][1]] = i + 1
	print(*ans)


import sys
input = lambda : sys.stdin.readline().rstrip()
from heapq import *
for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	a = [[-n, 0, n - 1]]
	for i in range(n):
		cur = heappop(a)
		if cur[0] & 1:
			l = (cur[0] + 1) // 2
			if l:
				heappush(a, [l, cur[1], cur[1] - l - 1])
			if l:
				heappush(a, [l, cur[1] - l + 1, cur[2]])
			ans[cur[1] - l] = i + 1
		else:
			s = cur[0] // 2 + 1
			e = cur[0] // 2
			if s:
				heappush(a, [s, cur[1], cur[1] - s - 1])
			if e:
				heappush(a, [e, cur[1] - s + 1, cur[2]])
			ans[cur[1] - s] = i + 1
	print(*ans)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	n = INT()
	temp = [0] * (n + 1)
	h = [(-n, 1)]
	heapify(h)
	for i in range(1, n + 1):
		popped = heappop(h)
		l = popped[1]
		r = l - popped[0] - 1
		mid = (l + r) // 2
		temp[mid] = i
		heappush(h, (l - mid, l))
		heappush(h, (mid - r, mid + 1))
	print(*temp[1:])
	t -= 1


import heapq

class Segment:

	def __init__(self, li, ri) -> None:
		self.size = ri - li + 1
		self.li = li
		self.ri = ri

	def __str__(self) -> str:
		return '(' + str(self.size) + ', ' + str(self.li) + ')'

def comparator(s, o):
	if o.size > s.size:
		return False
	if o.size < s.size:
		return True
	return s.li < o.li
setattr(Segment, '__lt__', comparator)
for _ in range(int(input())):
	n = int(input())
	arr = [0 for _ in range(n)]
	segs = [Segment(1, n)]
	for i in range(1, n + 1):
		seg = heapq.heappop(segs)
		l = seg.size
		if l % 2:
			mp = (seg.li + seg.ri) // 2
		else:
			mp = (seg.li + seg.ri - 1) // 2
		arr[mp - 1] = i
		if seg.size > 1:
			if seg.li < mp:
				heapq.heappush(segs, Segment(seg.li, mp - 1))
			if seg.ri > mp:
				heapq.heappush(segs, Segment(mp + 1, seg.ri))
	print(*arr)


import math

def task(n):
	table = {}
	for i in range(0, n):
		table[i] = []
	table[n] = [[1, n, 1]]
	array = [0] * n
	i = 0
	for size in reversed(range(1, n + 1)):
		if len(table[size]) == 0:
			continue
		intervals = sorted(table[size], key=lambda x: x[0])
		for interval in intervals:
			i += 1
			(l, r) = (interval[0], interval[1])
			if (r - l + 1) % 2 == 0:
				index = (l + r - 1) // 2
			else:
				index = (l + r) // 2
			array[index - 1] = i
			if l <= index - 1:
				intervalsize = index - 1 - l + 1
				table[intervalsize].append([l, index - 1])
			if index + 1 <= r:
				intervalsize = r - index - 1 + 1
				table[intervalsize].append([index + 1, r])
	print(' '.join(map(str, array)))
t = int(input())
for i in range(0, t):
	n = int(input())
	task(n)


from sys import stdin, gettrace
import heapq
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		n = int(input())
		final = [0] * (n + 1)
		li = []
		heapq.heapify(li)
		heapq.heappush(li, (n, 1, n))
		count = 1
		while count <= n:
			(ll, node_left, node_right) = heapq.heappop(li)
			final[(node_left + node_right) // 2] = count
			count += 1
			if (node_left + node_right) // 2 - node_left > 0:
				heapq.heappush(li, (-((node_left + node_right) // 2 - node_left), node_left, (node_left + node_right) // 2 - 1))
			if node_right - (node_left + node_right) // 2 > 0:
				heapq.heappush(li, (-(node_right - (node_left + node_right) // 2), (node_left + node_right) // 2 + 1, node_right))
		print(*final[1:])
	t = int(input())
	for i in range(t):
		solve()
main()


def solve(l, r):
	if l > r:
		return
	m = (l + r) // 2
	a[m] = (l - r, m)
	solve(l, m - 1)
	solve(m + 1, r)
t = int(input())
for w in range(t):
	n = int(input())
	a = b = [0] * (n + 1)
	solve(1, n)
	for (i, j) in enumerate(sorted(a[1:n + 1]), start=1):
		b[j[1]] = i
	print(*b[1:n + 1])


class node:

	def __init__(self, val):
		self.left = None
		self.right = None
		self.ind = val
		self.range = (0, 0)
from heapq import heappop, heappush

class Node:

	def __init__(self, vec):
		self.vec = vec

	def __lt__(self, other):
		if other.vec[0] > self.vec[0]:
			inv = False
			(left, right) = (self, other)
		else:
			inv = True
			(left, right) = (other, self)
		if -left.vec[0] + left.vec[1] + 1 < -right.vec[0] + right.vec[1] + 1:
			if inv == False:
				return False
			return True
		if inv == False:
			return True
		return False
for t in range(int(input())):
	n = int(input())
	lf = 0
	rt = n - 1
	l = [0 for i in range(n)]
	stack = []
	heappush(stack, Node((lf, rt)))
	i = 0
	while stack:
		i += 1
		if i > n:
			break
		root = heappop(stack)
		root = root.vec
		if (root[1] - root[0] + 1) % 2 == 0:
			mid = (root[0] + root[1] - 1) // 2
		else:
			mid = (root[0] + root[1]) // 2
		l[mid] = i
		if root[0] == root[1]:
			continue
		left = (root[0], mid - 1)
		right = (mid + 1, root[1])
		if -left[0] + left[1] + 1 < -right[0] + right[1] + 1:
			heappush(stack, Node(right))
			heappush(stack, Node(left))
		else:
			heappush(stack, Node(left))
			heappush(stack, Node(right))
	for i in range(n):
		print(l[i], end=' ')
	print()


def push(a, b):
	if a > b:
		return
	mid = (a + b) // 2
	c.append([b - a, -1 * a])
	push(mid + 1, b)
	push(a, mid - 1)
for _ in range(int(input())):
	n = int(input())
	c = []
	a = [0] * n
	push(0, n - 1)
	c.sort(reverse=True)
	for i in range(n):
		d = c[i][0] // 2 - c[i][1]
		a[d] = i + 1
	print(*a)


from heapq import *
for _ in range(int(input())):
	n = int(input())
	l1 = [(1 - n, 0, n - 1)]
	heapify(l1)
	q = [0] * n
	for x in range(1, n + 1):
		j = heappop(l1)
		t = (j[1] + j[2]) // 2
		q[t] = x
		if j[1] < t:
			heappush(l1, (j[1] - (t - 1), j[1], t - 1))
		if j[2] > t:
			heappush(l1, (t + 1 - j[2], t + 1, j[2]))
	print(*q)


import heapq

class HeapNode:

	def __init__(self, i, j):
		self.i = i
		self.j = j
		self.count = j - i + 1

def test(a, b):
	if a.count == b.count:
		return a.i < b.i
	else:
		return a.count > b.count
setattr(HeapNode, '__lt__', lambda self, other: test(self, other))
t = int(input())
for _ in range(t):
	n = int(input())
	out = [0] * n
	i = 1
	heap = list()
	heapq.heappush(heap, HeapNode(0, n - 1))
	while heap:
		x = heapq.heappop(heap)
		if x.count % 2 == 0:
			pivot = (x.i + x.j - 1) // 2
		else:
			pivot = (x.i + x.j) // 2
		out[pivot] = i
		i += 1
		(l1, r1) = (x.i, pivot - 1)
		(l2, r2) = (pivot + 1, x.j)
		if r1 - l1 + 1 > 0:
			heapq.heappush(heap, HeapNode(l1, r1))
		if r2 - l2 + 1 > 0:
			heapq.heappush(heap, HeapNode(l2, r2))
	for o in out:
		print(o, end=' ')
	print()


import heapq as heap
t = int(input())
while t != 0:
	n = int(input())
	ans = list()
	for i in range(n):
		ans.append(0)
	list1 = list()
	heap.heappush(list1, [-n, 0, n - 1])
	count = 1
	while len(list1) > 0:
		temp = heap.heappop(list1)
		mid = (temp[1] + temp[2]) // 2
		ans[mid] = count
		count += 1
		length1 = temp[2] - (mid + 1) + 1
		length2 = mid - 1 - temp[1] + 1
		if length2 > 0:
			heap.heappush(list1, [-length2, temp[1], mid - 1])
		if length1 > 0:
			heap.heappush(list1, [-length1, mid + 1, temp[2]])
	print(*ans)
	t -= 1


from heapq import heappush, heappop
for test in range(int(input())):
	n = int(input())
	pq = []
	i = 1
	res = [-1] * n
	heappush(pq, [-n, 0, n - 1])
	while pq:
		(d, left, right) = heappop(pq)
		if (left - right) % 2 == 0:
			indice = (left + right) // 2
		else:
			indice = (left + right - 1) // 2
		res[indice] = i
		if left <= indice - 1:
			heappush(pq, [-(indice - 1 - left), left, indice - 1])
		if indice + 1 <= right:
			heappush(pq, [-(right - indice - 1), indice + 1, right])
		i += 1
	print(' '.join(map(str, res)))


import sys, math, cmath, time, bisect
from collections import deque
start_time = time.time()
tt = 0
temp = []

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def qw(a, q, w, qq):
	if a.get(q):
		bisect.insort(a[q], w)
	else:
		a[q] = deque([w])
		bisect.insort(qq, q)
	return (a, qq)

def qqwwqqww(a, b):
	global temp
	if a > b:
		return
	mid = (a + b) // 2
	temp.append((b - a, -mid))
	qqwwqqww(mid + 1, b)
	qqwwqqww(a, mid - 1)

def solve():
	n = inp()
	if n > 10 ** 5:
		global temp
		q = [0] * (n + 1)
		temp = []
		qqwwqqww(1, n)
		temp.sort(reverse=True)
		t = 1
		for i in temp:
			q[abs(i[1])] = t
			t += 1
	else:
		c = 0
		q = ['#'] + [0] * n
		w = dict()
		qwqw = []
		(w, qwqw) = qw(w, n, [1, n], qwqw)
		for i in range(n):
			qqww = qwqw[-1]
			qq = w[qqww].popleft()
			if not w[qqww]:
				w.pop(qqww)
				qwqw.pop()
			l = qq[0]
			r = qq[1]
			ww = (l + r) // 2
			q[ww] = i + 1
			if l != r:
				if ww - l > 0:
					(w, qwqw) = qw(w, ww - l, [l, ww - 1], qwqw)
				if r - ww > 0:
					(w, qwqw) = qw(w, r - ww, [ww + 1, r], qwqw)
	print(*q[1:])

def main():
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
	sys.stdout.close()

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


import heapq
for _ in range(int(input())):
	n = int(input())
	q = [[n, 0, n - 1]]
	ans = [0] * n
	i = 0
	while len(q) != 0:
		(_, a, b) = heapq.heappop(q)
		i += 1
		mid = (a + b) // 2
		ans[mid] = i
		if a < mid:
			heapq.heappush(q, [-mid + a, a, mid - 1])
		if mid < b:
			heapq.heappush(q, [-b + mid, mid + 1, b])
	for (i, x) in enumerate(ans):
		ans[i] = str(x)
	print(' '.join(ans))


import sys
input = sys.stdin.readline
rInt = lambda : int(input())
mInt = lambda : map(int, input().split())
rLis = lambda : list(map(int, input().split()))
from heapq import *
t = rInt()
for _ in range(t):
	n = rInt()
	out = [0] * n
	q = []
	heappush(q, (-n, 0))
	curr = 0
	while q:
		curr += 1
		nex = heappop(q)
		length = -nex[0]
		start = nex[1]
		if length % 2:
			out[start + length // 2] = curr
			if length // 2:
				heappush(q, (-(length // 2), start))
				heappush(q, (-(length // 2), start + length // 2 + 1))
		else:
			half = length // 2
			out[start + length // 2 - 1] = curr
			heappush(q, (-(length // 2), start + length // 2))
			if length > 2:
				heappush(q, (-(length // 2 - 1), start))
	print(*out, sep=' ')


import heapq

def solve(n, ans):
	arr = [0] * n
	op = 1
	heap = []
	heapq.heappush(heap, (-n, 0, n - 1))
	while heap:
		(zeroes, l, r) = heapq.heappop(heap)
		if (r - l + 1) % 2 != 0:
			mid = (l + r) // 2
		else:
			mid = (l + r - 1) // 2
		arr[mid] = op
		op += 1
		if l <= mid - 1:
			heapq.heappush(heap, (l - mid, l, mid - 1))
		if mid + 1 <= r:
			heapq.heappush(heap, (mid - r, mid + 1, r))
	ans.append(arr)

def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		solve(n, ans)
	for i in ans:
		for j in i:
			print(j, end=' ')
		print()
main()


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	res = [0] * (n + 1)
	a = [(-n, 1, n)]
	count = 1
	while a:
		(_, l, r) = heapq.heappop(a)
		middle = (l + r) // 2
		res[middle] = count
		count += 1
		if l < middle:
			heapq.heappush(a, (l - middle, l, middle - 1))
		if middle < r:
			heapq.heappush(a, (middle - r, middle + 1, r))
	print(*res[1:n + 1])


from sys import stdin, gettrace
from heapq import heappush, heappop
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		n = int(input())
		hp = []
		heappush(hp, (-n, 0))
		res = [0] * n
		for i in range(1, n + 1):
			(len, start) = heappop(hp)
			mid = start + (-len - 1) // 2
			res[mid] = i
			if mid - start > 0:
				heappush(hp, (start - mid, start))
			if start - len - (mid + 1) > 0:
				heappush(hp, (-(start - len - (mid + 1)), mid + 1))
		print(' '.join(map(str, res)))
	q = int(input())
	for _ in range(q):
		solve()
main()


nCasos = int(input())
for _ in range(nCasos):
	sub = int(input())
	result = [0] * (sub + 1)
	matriz = [[] for _ in range(sub + 1)]
	matriz[sub] = [1]
	count = 1
	for i in range(sub, 0, -1):
		if len(matriz[i]) > 0:
			subMatriz = sorted(matriz[i])
			for k in subMatriz:
				if (i - 1) // 2 > 0:
					matriz[(i - 1) // 2].append(k)
				result[k + (i - 1) // 2] = count
				count += 1
				matriz[i // 2].append(k + (i + 1) // 2)
	print(' '.join(list(map(str, result[1:]))))


import sys
import heapq
for t in range(int(input())):
	n = int(input())
	a = [0] * (n + 1)
	h = []
	heapq.heappush(h, (-n, 1, n))
	for i in range(n):
		el = heapq.heappop(h)
		if (el[2] - el[1] + 1) % 2 == 0:
			index = (el[2] + el[1] - 1) // 2
			a[index] = i + 1
			if el[2] == el[1]:
				continue
			if index > 1:
				l = el[1]
				r = index - 1
				heapq.heappush(h, [l - r, l, r])
			if index < n:
				l = index + 1
				r = el[2]
				heapq.heappush(h, [l - r, l, r])
		else:
			index = (el[1] + el[2]) // 2
			a[index] = i + 1
			if el[2] == el[1]:
				continue
			if index > 1:
				l = el[1]
				r = index - 1
				heapq.heappush(h, [l - r, l, r])
			if index < n:
				l = index + 1
				r = el[2]
				heapq.heappush(h, [l - r, l, r])
	print(*a[1:])


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(val + '\n')
from heapq import heappush, heappop
for _ in range(int(input().strip())):
	n = int(input().strip())
	zeros = [[n - 1, 0, n - 1]]
	array = [0 for i in range(n)]
	for i in range(1, n + 1):
		(length, l, r) = heappop(zeros)
		index = (r + l) // 2
		array[index] = i
		if r != l:
			if r == l + 1:
				heappush(zeros, [-1, r, r])
			else:
				heappush(zeros, [-(index - l), l, index - 1])
				heappush(zeros, [-(r - index), index + 1, r])
	print(' '.join(map(str, array)))


import sys
import heapq
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
for tt in range(int(input())):
	n = int(input())
	arr = [0] * n
	seg = [(-n, 0, n - 1)]
	heapq.heapify(seg)
	for i in range(n):
		(gar, l, r) = heapq.heappop(seg)
		if r - l + 1 & 1:
			mid = (r + l) // 2
			arr[mid] = i + 1
		else:
			mid = (r + l - 1) // 2
			arr[mid] = i + 1
		if l <= mid - 1:
			heapq.heappush(seg, (-(mid - 1 - l + 1), l, mid - 1))
		if r >= mid + 1:
			heapq.heappush(seg, (-(r - mid - 1 + 1), mid + 1, r))
	print(*arr, sep=' ')


from collections import Counter
import math
mod = 10 ** 9 + 7
import heapq
for i in range(int(input())):
	n = int(input())
	h = []
	heapq.heappush(h, (-n, 1, n))
	ans = [0] * n
	for i in range(1, n + 1):
		x = heapq.heappop(h)
		l = x[1]
		r = x[2]
		mid = -(-(r + l - 1) // 2)
		ans[mid - 1] = i
		if mid != l:
			heapq.heappush(h, (-(mid - l), l, mid - 1))
		if mid != r:
			heapq.heappush(h, (-(r - mid), mid + 1, r))
	print(*ans)


def inverse_permutation(arr):
	inverse = [0] * len(arr)
	for (i, (el, runlen)) in enumerate(arr):
		inverse[el - 1] = (i, runlen)
	return inverse
solve_dict = {1: [(1, 1)], 2: [(1, 2), (2, 1)]}

def solve(n):
	if n in solve_dict:
		return solve_dict[n]
	answer = [None] * n
	k = (n - 1) // 2
	answer[k] = (1, n)
	lip = inverse_permutation(solve(k))
	rip = inverse_permutation(solve(n - k - 1))
	left_i = 0
	right_i = 0
	for i in range(2, n + 1):
		left_run_length = lip[left_i][1]
		right_run_length = rip[right_i][1]
		if left_run_length >= right_run_length:
			answer[lip[left_i][0]] = (i, lip[left_i][1])
			left_i += 1
			if left_i == k:
				while right_i < n - k - 1:
					i += 1
					answer[rip[right_i][0] + k + 1] = (i, rip[right_i][1])
					right_i += 1
				break
		else:
			answer[rip[right_i][0] + k + 1] = (i, rip[right_i][1])
			right_i += 1
			if right_i == n - k - 1:
				while left_i < k:
					i += 1
					answer[lip[left_i][0]] = (i, lip[left_i][1])
					left_i += 1
				break
	solve_dict[n] = answer
	return answer
t = int(input())
for _ in range(t):
	n = int(input())
	answer = solve(n)
	res = ''
	for x in answer:
		res += str(x[0]) + ' '
	res = res[:-1]
	print(res)


from heapq import *
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	h = [(-n, 0, n - 1)]
	iterNo = 1
	while len(h) > 0:
		(_, i, j) = heappop(h)
		mid = (i + j) // 2
		a[mid] = iterNo
		iterNo += 1
		if mid > i:
			heappush(h, (i - mid, i, mid - 1))
		if mid < j:
			heappush(h, (mid - j, mid + 1, j))
	print(*a)


import sys
input = sys.stdin.readline

def build(l, r, a):
	if l > r:
		return
	if l == r:
		a[l] = 1
		return
	m = (l + r) // 2
	a[m] = r - l + 1
	build(l, m - 1, a)
	build(m + 1, r, a)

def solve(a):
	res = []
	for ii in range(len(a)):
		res.append((a[ii], ii))
	res.sort(key=lambda x: (-x[0], x[1]))
	val = 1
	ans = [0 for _ in range(len(res))]
	for el in res:
		ans[el[1]] = val
		val += 1
	return ' '.join(map(str, ans))
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0 for _ in range(n)]
	build(0, n - 1, a)
	print(solve(a))


import heapq

def prar(n):
	i = 1
	ivals = []
	ivals.append((-n, 1, n))
	a = [0 for j in range(n)]
	while len(ivals) > 0:
		cval = heapq.heappop(ivals)
		ns = (cval[1] + cval[2]) // 2
		a[ns - 1] = i
		if cval[1] < cval[2]:
			if cval[1] <= ns - 1:
				heapq.heappush(ivals, (-(1 + ns - 1 - cval[1]), cval[1], ns - 1))
			if ns + 1 <= cval[2]:
				heapq.heappush(ivals, (-(1 + cval[2] - ns - 1), ns + 1, cval[2]))
		i += 1
	print(' '.join(map(str, a)))
t = int(input())
for i in range(t):
	n = int(input())
	prar(n)


import heapq
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	que = [(-n, 0, n - 1)]
	heapq.heapify(que)
	i = 1
	while que:
		(len, l, r) = heapq.heappop(que)
		if len % 2 == 1:
			a[(l + r) // 2] = i
			if r != l:
				nl = (-(r - l) // 2, l, (l + r) // 2 - 1)
				nr = (-(r - l) // 2, (l + r) // 2 + 1, r)
				heapq.heappush(que, nl)
				heapq.heappush(que, nr)
		else:
			a[(l + r - 1) // 2] = i
			nl = (-(r - l - 1) // 2, l, (l + r - 1) // 2 - 1)
			nr = (-(r - l + 1) // 2, (l + r - 1) // 2 + 1, r)
			if r == l + 1:
				heapq.heappush(que, nr)
			else:
				heapq.heappush(que, nr)
				heapq.heappush(que, nl)
		i += 1
	print(*a)


import sys
input = lambda : sys.stdin.readline().rstrip()
from heapq import heapify, heappop, heappush
out = []
t = int(input())
for _ in range(t):
	n = int(input())
	a = [[-n, 1, n]]
	ans = [0 for _ in range(n)]
	heapify(a)
	idx = 1
	while len(a) > 0:
		(length, start, end) = heappop(a)
		if start <= 0 or end > n:
			continue
		if length % 2 == 1:
			div_idx = (start + end) // 2
		else:
			div_idx = (start + end - 1) // 2
		ans[div_idx - 1] = idx
		if start - 1 <= div_idx - 2 and ans[start - 1] == 0:
			l = min(start, div_idx - 1)
			r = max(start, div_idx - 1)
			heappush(a, [-(r - l + 1), l, r])
		if div_idx <= end - 1 and ans[end - 1] == 0:
			l = min(end, div_idx + 1)
			r = max(end, div_idx + 1)
			heappush(a, [-(r - l + 1), l, r])
		idx += 1
	out.append(' '.join(map(str, ans)))
print('\n'.join(out))


def rec(l, r):
	global pos
	if l > r:
		return
	m = (l + r) // 2
	pos[m] = [l - r, m]
	rec(l, m - 1)
	rec(m + 1, r)

def zeroes(n):
	ans = [0] * n
	global pos
	rec(0, n - 1)
	for (i, j) in enumerate(sorted(pos)):
		ans[j[1]] = i + 1
	print(*ans)
	return ''
for i in range(int(input())):
	a = int(input())
	pos = [0] * a
	print(zeroes(a))


def seg(a, b):
	if a > b:
		return
	global arr
	global ind
	arr.append((b - a, -a))
	m = a + (b - a) // 2
	ind[b - a, -a] = m
	seg(a, m - 1)
	seg(m + 1, b)
for _ in range(int(input())):
	n = int(input())
	arr = []
	ind = {}
	ans = [0] * n
	seg(0, n - 1)
	arr = sorted(arr, reverse=True)
	for i in range(n):
		index = ind[arr[i]]
		ans[index] = i + 1
	print(*ans)


import sys
import heapq
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(sys.stdin.readline())
	list_a = [0] * n
	list_queue = [[n - 1, 0, n - 1]]
	count = 1
	while list_queue:
		(cost, now_l, now_r) = heapq.heappop(list_queue)
		mid = (now_l + now_r) // 2
		list_a[mid] = count
		count += 1
		if now_l == now_r:
			continue
		if now_l <= mid - 1:
			heapq.heappush(list_queue, [100000 - (mid - now_l), now_l, mid - 1])
		if mid + 1 <= now_r:
			heapq.heappush(list_queue, [100000 - (now_r - mid), mid + 1, now_r])
	print(*list_a)


import sys
import heapq
import collections

def set_debug(debug_mode=False):
	if debug_mode:
		fin = open('input.txt', 'r')
		sys.stdin = fin
t = int(input())
for ti in range(1, t + 1):
	n = int(input())
	pq = []
	heapq.heapify(pq)
	res = [0] * n
	cnt = 1
	heapq.heappush(pq, (-n, 0))
	while cnt <= n:
		(l, pos) = heapq.heappop(pq)
		l = -l
		if l % 2 == 0:
			cur = pos + l // 2 - 1
			res[cur] = cnt
			if l > 2:
				heapq.heappush(pq, (-(l // 2 - 1), pos))
			heapq.heappush(pq, (-l // 2, cur + 1))
		else:
			cur = pos + (l - 1) // 2
			res[cur] = cnt
			if l > 1:
				heapq.heappush(pq, (-(l - 1) // 2, pos))
				heapq.heappush(pq, (-(l - 1) // 2, cur + 1))
		cnt += 1
	print(' '.join([str(x) for x in res]))


from sys import stdin, stdout
import heapq
import math

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		lis = []
		arr = [0] * n
		heapq.heapify(lis)
		heapq.heappush(lis, (-1 * n, 0, n - 1))
		value = 1
		while lis:
			(size, l, r) = heapq.heappop(lis)
			size = size * -1
			if l == r:
				arr[l] = str(value)
				value += 1
				continue
			pos = 0
			if size % 2 == 0:
				pos = (l + r - 1) // 2
			else:
				pos = (l + r) // 2
			arr[pos] = str(value)
			value += 1
			if pos == l:
				heapq.heappush(lis, (l - r, l + 1, r))
			else:
				heapq.heappush(lis, (pos - r, pos + 1, r))
				heapq.heappush(lis, (l - pos, l, pos - 1))
		stdout.write(' '.join(arr) + '\n')
main()


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby

def Golf():
	(*a,) = map(int, open(0))

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def bit_combination(n, base=2):
	rt = []
	for tb in range(base ** n):
		s = [tb // base ** bt % base for bt in range(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(1, 0), (-1, 0), (0, 1), (0, -1)]
EightNb = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('EWNS', FourNb))
l_alp = string.ascii_lowercase
sys.setrecursionlimit(10 ** 7)
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, ls=None, init=True, index=0):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			if ls == None:
				self.stdin(inp_size, index=index)
			else:
				self.size = len(ls) + 1
				(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.size = int(input())
		else:
			self.size = inp_size
		(self.edges, _) = GI(self.size, self.size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.size = len(ls) + 1
		(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def __str__(self):
		return str(self.edges)

	def dfs(self, x, func=lambda prv, nx, dist: prv + dist, root_v=0):
		q = deque()
		q.append(x)
		v = [-1] * self.size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == -1:
					q.append(nb)
					v[nb] = func(v[c], nb, d)
		return v

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.size
		self.ETout = [-1] * self.size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))])

	def query_id(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][max(0, r - (1 << N))])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))]):
			b = a
		return b

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)

class Comb:

	def __init__(self, n, mo=10 ** 9 + 7):
		self.fac = [0] * (n + 1)
		self.inv = [1] * (n + 1)
		self.fac[0] = 1
		self.fact(n)
		for i in range(1, n + 1):
			self.fac[i] = i * self.fac[i - 1] % mo
			self.inv[n] *= i
			self.inv[n] %= mo
		self.inv[n] = pow(self.inv[n], mo - 2, mo)
		for i in range(1, n):
			self.inv[n - i] = self.inv[n - i + 1] * (n - i + 1) % mo
		return

	def fact(self, n):
		return self.fac[n]

	def invf(self, n):
		return self.inv[n]

	def comb(self, x, y):
		if y < 0 or y > x:
			return 0
		return self.fac[x] * self.inv[x - y] * self.inv[y] % mo
show_flg = False
show_flg = True
ans = 0

def solve(n):
	q = [(-n, (0, n - 1))]
	a = []
	while q:
		(x, (l, r)) = heappop(q)
		if x % 2 == 1 or True:
			m = (l + r) // 2
			a.append((l + r) // 2)
			if m - l > 0:
				heappush(q, (-(m - l), (l, m - 1)))
			if r - m > 0:
				heappush(q, (-(r - m), (m + 1, r)))
	return a
T = I()
for _ in range(T):
	n = I()
	x = solve(n)
	ans = [0] * n
	for i in range(n):
		ans[x[i]] = i + 1
	print(*ans)


from heapq import heapify, heappush, heappop
for _ in range(int(input())):
	a = int(input())
	q = 1
	b = [0] * a
	v = [(-a, 1, a)]
	heapify(v)
	while v:
		k = heappop(v)
		ind = k[1] + -(k[0] + 1) // 2
		b[ind - 1] = q
		q += 1
		if ind - k[1]:
			heappush(v, (-(ind - k[1]), k[1], ind - 1))
		if k[2] - ind:
			heappush(v, (-(k[2] - ind), ind + 1, k[2]))
	print(*b)


d = dict()

def seive(s, e):
	if s >= e:
		return
	mid = (s + e) // 2
	d[s, mid - 1] = min(mid - s, e - mid)
	d[mid + 1, e] = max(mid - s, e - mid)
	seive(s, mid - 1)
	seive(mid + 1, e)
for i in range(int(input())):
	n = int(input())
	d[1, n] = n
	seive(1, n)
	l = [0] * n
	j = 1
	for i in sorted(d, key=d.get, reverse=True):
		if j > n:
			break
		mid = (i[0] + i[1]) // 2
		l[mid - 1] = j
		j += 1
	for i in l:
		print(i, end=' ')
	print('')
	d.clear()


from heapq import heappush, heappop
t = int(input())
for i in range(t):
	n = int(input())
	result = [0] * (n + 1)
	pq = [(-n, (1, n))]
	for j in range(n):
		(l, r) = heappop(pq)[1]
		if (r - l + 1) % 2 == 1:
			m = (l + r) // 2
		else:
			m = (l + r - 1) // 2
		result[m] = j + 1
		if l != m:
			heappush(pq, (-(m - l), (l, m - 1)))
		if r != m:
			heappush(pq, (-(r - m), (m + 1, r)))
	result.remove(0)
	print(*result)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
for _ in range(int(input())):
	n = int(input())
	ans = [0 for i in range(n + 1)]
	stack = deque()
	stack.append((1, n))
	d = {i: [] for i in range(1, n + 1)}
	z = set()
	z.add(1)
	while stack:
		a = stack.pop()
		if a[0] <= a[1]:
			if a[0] == a[1]:
				d[1].append(a[0])
			else:
				d[a[1] - a[0] + 1].append(a)
				z.add(a[1] - a[0] + 1)
				if (a[1] - a[0] + 1) % 2 != 0:
					stack.append((a[0], (a[1] + a[0]) // 2 - 1))
					stack.append(((a[1] + a[0]) // 2 + 1, a[1]))
				else:
					stack.append(((a[1] + a[0] - 1) // 2 + 1, a[1]))
					stack.append((a[0], (a[1] + a[0] - 1) // 2 - 1))
	z = list(z)
	z.sort(reverse=True)
	t = 1
	for i in z:
		f = sorted(d[i])
		if i == 1:
			for k in f:
				ans[k] = t
				t += 1
		else:
			for k in f:
				ans[(k[1] + k[0]) // 2] = t
				t += 1
	print(*ans[1:])


import traceback
import math
from collections import defaultdict, Counter
from functools import lru_cache
from itertools import accumulate
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def geti():
	return int(input())

def gets():
	return input()

def getil():
	return list(map(int, input().split()))

def getsl():
	return input().split()

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]

def get_acc(a):
	return list(accumulate(a))
inf = float('inf')
mod = 10 ** 9 + 7

def main():
	n = geti()
	ans = [0] * n
	q = []

	def pairs(l, r):
		if l > r:
			return
		m = (l + r) // 2
		q.append([r - l, m])
		pairs(l, m - 1)
		pairs(m + 1, r)
	pairs(0, n - 1)
	q.sort(key=lambda x: (-x[0], x[1]))
	k = 1
	for (_, i) in q:
		ans[i] = k
		k += 1
	return ans
try:
	Test = geti()
	answers = []
	for _ in range(Test):
		ans = main()
		answers.append(ans)
	for i in answers:
		print(*i)
except Exception as e:
	print(e)
	traceback.print_exc()


import heapq

def RA():
	return list(map(int, input().split()))

def solve():
	n = int(input())
	q = [(-n, 0, n - 1)]
	heapq.heapify(q)
	ans = [0] * n
	for i in range(1, n + 1):
		(length, l, r) = heapq.heappop(q)
		pos = (l + r) // 2
		ans[pos] = i
		if pos - 1 >= l:
			heapq.heappush(q, (-(pos - l), l, pos - 1))
		if pos + 1 <= r:
			heapq.heappush(q, (-(r - pos), pos + 1, r))
	print(*ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
import operator
for _ in range(t):
	n = int(input())
	if n == 1:
		print(1)
	elif n == 2:
		print(1, 2)
	else:
		lis = []
		for i in range(n):
			lis.append(0)
		stack = []
		lis[(n - 1) // 2] = 1
		if n % 2 == 1:
			stack.append((-((n - 1) // 2 - 1), 0, (n - 1) // 2 - 1))
			stack.append((-(n - 1 - ((n - 1) // 2 + 1)), (n - 1) // 2 + 1, n - 1))
		else:
			stack.append((-(n - 1 - ((n - 1) // 2 + 1)), (n - 1) // 2 + 1, n - 1))
			stack.append((-((n - 1) // 2 - 1), 0, (n - 1) // 2 - 1))
		next = 2
		j = 0
		k = 2
		prev = stack[0][0]
		while j < k:
			if stack[j][0] != prev:
				stack.sort(key=lambda x: (x[0], x[1]))
				prev = stack[j][0]
			i = stack[j]
			if i[2] - i[1] == 0:
				lis[i[1]] = next
			elif (i[2] - i[1] + 1) % 2 == 0:
				lis[(i[2] + i[1]) // 2] = next
				if i[2] != (i[2] + i[1]) // 2:
					stack.append((-(i[2] - ((i[2] + i[1]) // 2 + 1)), (i[2] + i[1]) // 2 + 1, i[2]))
					k += 1
				if i[1] != (i[2] + i[1]) // 2:
					stack.append((-((i[2] + i[1]) // 2 - 1 - i[1]), i[1], (i[2] + i[1]) // 2 - 1))
					k += 1
			else:
				lis[(i[2] + i[1]) // 2] = next
				if i[1] != (i[2] + i[1]) // 2:
					stack.append((-((i[2] + i[1]) // 2 - 1 - i[1]), i[1], (i[2] + i[1]) // 2 - 1))
					k += 1
				if i[2] != (i[2] + i[1]) // 2:
					stack.append((-(i[2] - ((i[2] + i[1]) // 2 + 1)), (i[2] + i[1]) // 2 + 1, i[2]))
					k += 1
			next += 1
			j += 1
		for i in lis:
			print(i, end=' ')
		print()


from queue import PriorityQueue
t = int(input())

def sub(l, r):
	if l > r:
		return
	m = (l + r) // 2
	a.append((l - r, m))
	sub(l, m - 1)
	sub(m + 1, r)
for _ in range(t):
	q = PriorityQueue()
	n = int(input())
	arr = [0] * n
	a = []
	sub(0, n - 1)
	k = 1
	a.sort()
	for (i, j) in a:
		arr[j] = k
		k += 1
	print(*arr)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [0] * n
		a[0] = 1
		pr = [[] for _ in range(n + 1)]
		pr[n].append(0)
		ct = 0
		for l in range(n, 0, -1):
			c = pr[l]
			c.sort()
			for x in c:
				mid = x + (l - 1) // 2
				ct += 1
				a[mid] = ct
				pr[mid - x].append(x)
				pr[x + l - 1 - mid].append(mid + 1)
		print(*a)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import heapq
import math
import bisect

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, input().split())

def rlinput():
	return list(map(int, input().split()))

def srlinput(fl=False):
	return sorted(list(map(int, input().split())), reverse=fl)

def main():
	n = iinput()
	res = [0 for i in range(n)]
	kucha = [(n, 0, n - 1)]
	i = 0
	while kucha:
		i += 1
		(left, right) = heapq.heappop(kucha)[1:]
		mid = (left + right) // 2
		res[mid] = i
		if left == right:
			continue
		if mid > left:
			heapq.heappush(kucha, (left - mid, left, mid - 1))
		if right > mid:
			heapq.heappush(kucha, (mid - right, mid + 1, right))
	print(*res)
for sdfghjkl in range(iinput()):
	main()


t = int(input())
for i in range(t):
	num = int(input())
	ans = [0] * num
	l = 0
	count = 1
	data = {num: [l]}
	lisp = [num]
	flag = 0
	for i in lisp:
		subseqs = sorted(data[i])
		n = i
		for j in subseqs:
			l = j
			r = l + n - 1
			if n % 2 == 0:
				pos = l + n // 2 - 1
				if n // 2 not in lisp:
					lisp.append(n // 2)
				if n // 2 - 1 not in lisp:
					lisp.append(n // 2 - 1)
				if n // 2 in data:
					data[n // 2].append(pos + 1)
				else:
					data[n // 2] = [pos + 1]
				if n // 2 - 1 in data:
					data[n // 2 - 1].append(l)
				else:
					data[n // 2 - 1] = [l]
				ans[pos] = count
				count += 1
			else:
				pos = l + n // 2
				if n // 2 not in lisp:
					lisp.append(n // 2)
				if n // 2 in data:
					data[n // 2].append(l)
					data[n // 2].append(pos + 1)
				else:
					data[n // 2] = [l, pos + 1]
				ans[pos] = count
				count += 1
			if count == num + 1:
				flag = 1
				break
		if flag == 1:
			break
	print(*ans)


from heapq import *
for _ in range(int(input())):
	n = int(input())
	arr = [0] * n
	ranges = [(n, 0, n - 1)]
	heapify(ranges)
	number = 1
	while ranges:
		(size, l, r) = heappop(ranges)
		if (r - l + 1) % 2:
			mid = (l + r) // 2
			arr[mid] = number
		else:
			mid = (l + r - 1) // 2
			arr[mid] = number
		if mid != l:
			heappush(ranges, (n - mid + l, l, mid - 1))
		if mid != r:
			heappush(ranges, (n - r + mid, mid + 1, r))
		number += 1
	print(*arr)


from heapq import *
import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	h = []
	ans = [0] * n
	ans[(n - 1) // 2] = 1
	cur = 2
	l1 = 0
	r1 = (n - 1) // 2 - 1
	l2 = (n - 1) // 2 + 1
	r2 = n - 1
	if l1 <= r1:
		heappush(h, [-(r1 - l1 + 1), l1])
	if l2 <= r2:
		heappush(h, [-(r2 - l2 + 1), l2])
	while h:
		v = heappop(h)
		ans[v[1] + (-v[0] - 1) // 2] = cur
		cur += 1
		l1 = v[1]
		r1 = v[1] + (-v[0] - 1) // 2 - 1
		l2 = v[1] + (-v[0] - 1) // 2 + 1
		r2 = v[1] + (-v[0] - 1)
		if l1 <= r1:
			heappush(h, [-(r1 - l1 + 1), l1])
		if l2 <= r2:
			heappush(h, [-(r2 - l2 + 1), l2])
	print(' '.join(map(str, ans)))


from math import gcd

def r():
	return map(int, input().split())

def l():
	return list(map(int, input().split()))

def i():
	return int(input())

def si():
	return input()

def pYes():
	print('YES')

def pNo():
	print('NO')

def plist(l):
	print(''.join(l))

def findm(a, b):
	if a > b:
		return
	mid = (a + b) // 2
	c.append([b - a, -1 * a])
	findm(mid + 1, b)
	findm(a, mid - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * n
	c = []
	findm(0, n - 1)
	c = sorted(c, reverse=True)
	for i in range(n):
		d = c[i][0] // 2 - c[i][1]
		arr[d] = i + 1
	print(*arr)


from collections import defaultdict
import sys
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353

def dfs(l, r):
	if l > r:
		return
	mid = (l + r) // 2
	A[mid] = (l - r, mid)
	dfs(l, mid - 1)
	dfs(mid + 1, r)
for CASES in range(int(input())):
	n = int(input())
	A = [(-inf, 0)] * (n + 1)
	B = [0] * (n + 1)
	t = 0
	dfs(1, n)
	A = sorted(A[1:])
	for (num, tup) in enumerate(A):
		B[tup[1]] = num + 1
	print(*B[1:])


import sys
input = sys.stdin.readline
from heapq import heappush, heappop

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))

def print_array(a):
	print(' '.join(map(str, a)))

def binary(a, l, r, i):
	if (r - l + 1) % 2 == 1:
		return (l + r) // 2
	return (l + r - 1) // 2

def solve(a, l, r, i):
	ans = a
	tupla = (-len(a), 0, len(a) - 1, ans)
	a = []
	heappush(a, tupla)
	while len(a):
		(size, ini, fim, cur) = heappop(a)
		split = binary(cur, ini, fim, i)
		if ans[split] != 0:
			continue
		ans[split] = i
		left = ans[ini:split]
		right = ans[split + 1:fim + 1]
		if len(right) > len(left):
			if len(right) > 0:
				heappush(a, (-len(right), split + 1, fim, right))
			if len(left) > 0:
				heappush(a, (-len(left), ini, split - 1, left))
		else:
			if len(left) > 0:
				heappush(a, (-len(left), ini, split - 1, left))
			if len(right) > 0:
				heappush(a, (-len(right), split + 1, fim, right))
		i += 1
	return ans
t = ii()
for _ in range(t):
	n = ii()
	a = [0] * n
	a = solve(a, 0, n - 1, 1)
	print_array(a)


from __future__ import division, print_function
MOD = 998244353
mod = 10 ** 9 + 7

def prepare_factorial():
	fact = [1]
	for i in range(1, 5005):
		fact.append(fact[-1] * i % mod)
	ifact = [0] * 5005
	ifact[5004] = pow(fact[5004], mod - 2, mod)
	for i in range(5004, 0, -1):
		ifact[i - 1] = i * ifact[i] % mod
	return (fact, ifact)
import sys
from bisect import bisect_left, bisect_right, insort
from math import floor, ceil, sqrt, degrees, atan, pi, log, sin, radians
from heapq import heappop, heapify, heappush
from collections import Counter, defaultdict, deque

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, fact, ifact):
	t = fact[n] * (ifact[r] * ifact[n - r]) % mod % mod
	return t

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // GCD(x, y)

def get_xor(n):
	return [n, 1, n + 1, 0][n % 4]

def bin_pow(a, b):
	res = 1
	while b:
		if b & 1:
			res = res * a
			b -= 1
		else:
			a = a * a
			b >>= 1
	return res

def main():
	T = int(input())
	while T:
		n = int(input())
		ans = [0] * n
		heap = [(-n, 0, n - 1)]
		cnt = 0
		while heap:
			(length, left, right) = heappop(heap)
			length *= -1
			if left > right:
				continue
			mid = left + right >> 1
			cnt += 1
			ans[mid] = cnt
			heappush(heap, (-1 * (mid - left), left, mid - 1))
			heappush(heap, (-1 * (right - mid), mid + 1, right))
		print(*ans)
		T -= 1
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys
import heapq

def solve(n):
	Ans = [0] * n
	hq = []
	heapq.heappush(hq, (-n, 0))
	cnt = 0
	while cnt < n:
		cnt += 1
		(l, idx) = heapq.heappop(hq)
		l *= -1
		center = idx + (l - 1) // 2
		Ans[center] = cnt
		heapq.heappush(hq, (-((l - 1) // 2), idx))
		heapq.heappush(hq, (-(l // 2), center + 1))
	return Ans

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		Ans = solve(n)
		sys.stdout.write(' '.join(map(str, Ans)) + '\n')
main()


from functools import cmp_to_key
from collections import deque
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def sli():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

class UnionFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)

def custom_sort(lista):

	def cmp(x, y):
		if x + y > y + x:
			return 1
		else:
			return -1
	return sorted(lista, key=cmp_to_key(cmp))
MOD = 10 ** 9 + 7
maxN = 10 ** 5
FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def coeffBinom(n, k):
	if n < k:
		return 0
	return divide(FACT[n], multiply(FACT[k], FACT[n - k]))

def primes(N):
	smallest_prime = [1] * (N + 1)
	prime = []
	smallest_prime[0] = 0
	smallest_prime[1] = 0
	for i in range(2, N + 1):
		if smallest_prime[i] == 1:
			prime.append(i)
			smallest_prime[i] = i
		j = 0
		while j < len(prime) and i * prime[j] <= N:
			smallest_prime[i * prime[j]] = min(prime[j], smallest_prime[i])
			j += 1
	return (prime, smallest_prime)

def gcd(a, b):
	a = abs(a)
	b = abs(b)
	(s, t, r) = (0, 1, b)
	(old_s, old_t, old_r) = (1, 0, a)
	while r != 0:
		quotient = old_r // r
		(old_r, r) = (r, old_r - quotient * r)
		(old_s, s) = (s, old_s - quotient * s)
		(old_t, t) = (t, old_t - quotient * t)
	return (old_r, old_s, old_t)

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def create_edges(m, unweighted=0):
	edges = list()
	if unweighted:
		for i in range(m):
			edges.append(li(lag=-1))
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			edges.append([w, x, y])
	return edges

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def connected(graph, n):
	v = dfs(graph, n, 0)
	for el in v:
		if el == -1:
			return False
	return True

def topological(graph, n):
	indegree = [0] * n
	for el in range(n):
		for child in graph[el]:
			indegree[child] += 1
	s = deque()
	for el in range(n):
		if indegree[el] == 0:
			s.append(el)
	order = []
	while s:
		el = s.popleft()
		order.append(el)
		for child in graph[el]:
			indegree[child] -= 1
			if indegree[child] == 0:
				s.append(child)
	if n == len(order):
		return (False, order)
	else:
		return (True, [])

def bipartite(graph, n):
	color = [-1] * n
	color[0] = 0
	s = [0]
	while s:
		el = s.pop()
		for child in graph[el]:
			if color[child] == color[el]:
				return False
			if color[child] == -1:
				s.append(child)
			color[child] = 1 - color[el]
	return True

def dijkstra(graph, n, A):
	dist = [float('inf') for i in range(n)]
	prev = [-1 for i in range(n)]
	dist[A] = 0
	pq = []
	heappush(pq, [0, A])
	while pq:
		[d_v, v] = heappop(pq)
		if d_v != dist[v]:
			continue
		for (to, w) in graph[v]:
			if dist[v] + w < dist[to]:
				dist[to] = dist[v] + w
				prev[to] = v
				heappush(pq, [dist[to], to])
	return (dist, prev)

def dijkstra_0_1(graph, n, A):
	dist = [float('inf') for i in range(n)]
	dist[A] = 0
	p = deque()
	p.append(A)
	while p:
		v = p.popleft()
		for (to, w) in graph[v]:
			if dist[v] + w < dist[to]:
				dist[to] = dist[v] + w
			if w == 1:
				q.append(to)
			else:
				q.appendleft(to)
	return dist

def floyd_warshall(graph, n):
	dist = [[float('inf') for _ in range(n)] for _ in range(n)]
	for i in range(n):
		dist[i][i] = 0
		for (child, d) in graph[i]:
			dist[i][child] = d
			dist[child][i] = d
	for k in range(n):
		for i in range(n):
			for j in range(j):
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
	return dist

def minimum_spanning_tree(edges, n):
	edges = sorted(edges)
	union_find = UnionFind(n)
	used_edges = list()
	for (w, x, y) in edges:
		if union_find.find(x) != union_find.find(y):
			union_find.merge(x, y)
			used_edges.append([w, x, y])
	return used_edges

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path

def finding_ancestors(parent, queries, n):
	steps = int(ceil(log(n, 2)))
	ancestors = [[-1 for i in range(n)] for j in range(steps)]
	ancestors[0] = parent
	for i in range(1, steps):
		for node in range(n):
			if ancestors[i - 1][node] != -1:
				ancestors[i][node] = ancestors[i - 1][ancestors[i - 1][node]]
	result = []
	for (node, k) in queries:
		ans = node
		if k >= n:
			ans = -1
		i = 0
		while k > 0 and ans != -1:
			if k % 2:
				ans = ancestors[i][ans]
			k = k // 2
			i += 1
		result.append(ans)
	return result

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def nearest_from_the_left_smaller_elements(arr):
	n = len(arr)
	res = [-1] * n
	s = []
	for (i, el) in enumerate(arr):
		while s and s[-1] >= el:
			s.pop()
		if s:
			res[i] = s[-1]
		s.append(el)
	return res

def sliding_window_minimum(arr, k):
	res = []
	q = deque()
	for (i, el) in enumerate(arr):
		while q and arr[q[-1]] >= el:
			q.pop()
		q.append(i)
		while q and q[0] <= i - k:
			q.popleft()
		if i >= k - 1:
			res.append(arr[q[0]])
	return res
for test in range(ii()):
	n = ii()
	pq = []
	i = 1
	res = [-1] * n
	heappush(pq, [-n, 0, n - 1])
	while pq:
		(d, left, right) = heappop(pq)
		if (left - right) % 2 == 0:
			indice = (left + right) // 2
		else:
			indice = (left + right - 1) // 2
		res[indice] = i
		if left <= indice - 1:
			heappush(pq, [-(indice - 1 - left), left, indice - 1])
		if indice + 1 <= right:
			heappush(pq, [-(right - indice - 1), indice + 1, right])
		i += 1
	print_list(res)


from heapq import heappush, heappop
for _ in range(int(input())):
	n = int(input())
	pq = [(-n, 1, n)]
	a = [0 for i in range(n + 1)]
	for i in range(1, n + 1):
		(sz, l, r) = heappop(pq)
		j = (l + r) // 2 if (r - l + 1) % 2 else (l + r - 1) // 2
		a[j] = i
		if j + 1 <= r:
			heappush(pq, (-(r - (j + 1) + 1), j + 1, r))
		if l <= j - 1:
			heappush(pq, (-(j - 1 - l + 1), l, j - 1))
	print(*a[1:])


from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	x = []
	heappush(x, (-n, 0, n - 1))
	arr = [0] * n
	for i in range(n):
		y = heappop(x)
		(l, r) = (y[1], y[2])
		mid = (l + r) // 2
		arr[mid] = i + 1
		if mid - l > 0:
			heappush(x, (-mid + l, l, mid - 1))
		if r - mid > 0:
			heappush(x, (-r + mid, mid + 1, r))
	print(*arr)


import sys
import heapq
from heapq import heappush, heappop

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(int(line.rstrip()))
	for i in range(1, len(q)):
		res = [0] * q[i]
		r = q[i]
		l = 1
		d = r - l + 1
		to_put = 1
		h = []
		heappush(h, (1, (l, r)))
		while len(h) != 0:
			curr = heappop(h)
			pair = curr[1]
			l = pair[0]
			r = pair[1]
			if (r - l + 1) % 2 == 0:
				middle = (l + r - 1) // 2
				res[middle - 1] = str(to_put)
			else:
				middle = (l + r) // 2
				res[middle - 1] = str(to_put)
			to_put += 1
			heappush(h, (-1 * (middle - l), (l, middle - 1)))
			heappush(h, (-1 * (r - middle), (middle + 1, r)))
			if to_put == q[i] + 1:
				break
		print(' '.join(res))
main()


import heapq
for ii in range(int(input())):
	n = int(input())
	h = []
	ans = [0 for i in range(n)]
	heapq.heappush(h, (-(n - 1), 1, n))
	i = 1
	while h != []:
		s = heapq.heappop(h)
		a = (s[1] + s[2]) // 2
		ans[a - 1] = i
		i += 1
		if s[1] != a:
			heapq.heappush(h, (-(a - 1 - s[1]), s[1], a - 1))
		if s[2] != a:
			heapq.heappush(h, (-(s[2] - a - 1), a + 1, s[2]))
	print(*ans)


for i in range(int(input())):
	n = int(input())
	a = [0] * (n + 1)
	b = [[] for i in range(n + 1)]
	b[n].append(1)
	j = n
	ccc = 1
	for x in range(n, 0, -1):
		if len(b[x]) > 0:
			c = sorted(b[x])
			for j in c:
				x1 = j
				x2 = x1 + x - 1
				if x1 == x2:
					a[x1] = ccc
					ccc += 1
				else:
					m = (x1 + x2) // 2
					a[m] = ccc
					ccc += 1
					if x1 < m:
						b[m - x1].append(x1)
					if m < x2:
						b[x2 - m].append(m + 1)
	print(*a[1:n + 1])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		t = [0] * n
		q = []
		heapq.heappush(q, (-n, 0, n - 1))
		qi = 1
		while q:
			(_, l, r) = heapq.heappop(q)
			m = (l + r) // 2
			t[m] = qi
			qi += 1
			if l < m:
				heapq.heappush(q, (-(m - l), l, m - 1))
			if m < r:
				heapq.heappush(q, (-(r - m), m + 1, r))
		rr.append(JA(t, ' '))
	return JA(rr, '\n')
print(main())


def input1(type=int):
	return type(input())

def input2(type=int):
	[a, b] = list(map(type, input().split()))
	return (a, b)

def input3(type=int):
	[a, b, c] = list(map(type, input().split()))
	return (a, b, c)

def input_array(type=int):
	return list(map(type, input().split()))

def input_string():
	s = input()
	return list(s)

def get_l(sz, m):
	md = sz // 2
	if sz % 2 == 0:
		md -= 1
	return m - md

def get_r(sz, m):
	return m + sz // 2

def mid_point(l, r):
	length = r - l + 1
	m = length // 2
	if length % 2 == 0:
		m -= 1
	return l + m

def break_here(l, r):
	m = mid_point(l, r)
	sz1 = m - 1 - l + 1
	sz2 = r - (m + 1) + 1
	return [(-sz1, mid_point(l, m - 1)), (-sz2, mid_point(m + 1, r))]

def main():
	t = input1()
	for ci in range(t):
		n = input1()
		import heapq as pq
		h = []
		pq.heappush(h, (-n, mid_point(0, n - 1)))
		ind = 1
		arr = [0 for _ in range(n)]
		while len(h):
			now = pq.heappop(h)
			arr[now[1]] = str(ind)
			ind += 1
			[a, b] = break_here(get_l(-now[0], now[1]), get_r(-now[0], now[1]))
			if a[0] < 0:
				pq.heappush(h, a)
			if b[0] < 0:
				pq.heappush(h, b)
		print(' '.join(arr))
	return
main()


from sys import stdin, stdout
from math import ceil, floor
import heapq

def find(N):
	Z = [0] * N
	arr = [(-N, 0)]
	k = 1
	while arr:
		(l, i) = heapq.heappop(arr)
		l *= -1
		if l == 0:
			continue
		j = i + l - 1
		Z[(i + j) // 2] = k
		l -= 1
		(a, b) = ((-floor(l / 2), i), (-ceil(l / 2), (i + j) // 2 + 1))
		heapq.heappush(arr, a)
		heapq.heappush(arr, b)
		k += 1
	return ' '.join(map(str, Z))

def main():
	for _ in range(int(stdin.readline())):
		N = int(stdin.readline())
		print(find(N))
main()


from heapq import heappush, heappop
t = int(input())
for z in range(t):
	n = int(input())
	l = [0] * n
	s = []
	heappush(s, (-n, 0, n - 1))
	for i in range(n):
		t = heappop(s)
		if (t[2] - t[1] + 1) % 2 == 0:
			index = (t[2] + t[1] - 1) // 2
			l[index] = i + 1
			if index - 1 >= t[1]:
				heappush(s, (-index + t[1], t[1], index - 1))
			if t[2] >= index + 1:
				heappush(s, (-t[2] + index, index + 1, t[2]))
		else:
			index = (t[2] + t[1]) // 2
			l[index] = i + 1
			if index - 1 >= t[1]:
				heappush(s, (-index + t[1], t[1], index - 1))
			if t[2] >= index + 1:
				heappush(s, (-t[2] + index, index + 1, t[2]))
	for i in range(n):
		print(l[i], end=' ')
	print()


import heapq

def func(n):
	q = []
	heapq.heappush(q, [-(n - 1 + 1), 1, n])
	j = 1
	q.append([1, n])
	while j <= n:
		x = heapq.heappop(q)
		mid = (x[1] + x[2]) // 2
		le = -x[0]
		b[mid] = j
		j += 1
		if le == 1:
			continue
		if mid - 1 >= x[1]:
			heapq.heappush(q, [-(mid - 1 - x[1] + 1), x[1], mid - 1])
		if mid + 1 <= x[2]:
			heapq.heappush(q, [-(x[2] - mid - 1 + 1), mid + 1, x[2]])
t = int(input())
while t:
	t -= 1
	n = int(input())
	b = [0] * (n + 1)
	func(n)
	print(*b[1:])


import sys
import heapq
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))

def solve(num):
	res = [0] * num
	count = 1
	q = [(-num, (0, num - 1))]
	while q:
		item = heapq.heappop(q)
		n = -item[0]
		l = item[1][0]
		r = item[1][1]
		if l == r:
			res[int(l)] = count
			count += 1
			continue
		if r == l + 1:
			res[int(l)] = count
			count += 1
			heapq.heappush(q, (-1, (r, r)))
			continue
		if (l + r) % 2 == 0:
			m = (l + r) / 2
			heapq.heappush(q, (-(m - l), (l, m - 1)))
			heapq.heappush(q, (-(r - m), (m + 1, r)))
		else:
			m = (l + r - 1) / 2
			heapq.heappush(q, (-(m - l), (l, m - 1)))
			heapq.heappush(q, (-(r - m), (m + 1, r)))
		res[int(m)] = count
		count += 1
	return res
t = inp()
for i in range(t):
	print(' '.join(map(str, solve(inp()))))


import heapq
t = int(input())
for T in range(t):
	n = int(input())
	a = [0 for _ in range(n)]
	hp = []
	length = n
	heapq.heappush(hp, (-length, 0, n - 1))
	for i in range(1, n + 1):
		(length, start, stop) = heapq.heappop(hp)
		mid = (start + stop) // 2
		a[mid] = i
		length = mid - start
		if start < mid:
			heapq.heappush(hp, (-length, start, mid - 1))
		length = stop - mid
		if mid < stop:
			heapq.heappush(hp, (-length, mid + 1, stop))
	print(*a, sep=' ')


import heapq

def solve():
	n = int(input())
	final = [0] * (n + 1)
	li = []
	heapq._heapify_max(li)
	li.append((n, -1, n))
	heapq._siftdown_max(li, 0, 0)
	count = 1
	while count <= n:
		(ll, node_left, node_right) = heapq._heappop_max(li)
		node_left = -node_left
		final[(node_left + node_right) // 2] = count
		count += 1
		if (node_left + node_right) // 2 - node_left > 0:
			li.append(((node_left + node_right) // 2 - node_left, -node_left, (node_left + node_right) // 2 - 1))
			heapq._siftdown_max(li, 0, len(li) - 1)
		if node_right - (node_left + node_right) // 2 > 0:
			li.append((node_right - (node_left + node_right) // 2, -((node_left + node_right) // 2 + 1), node_right))
			heapq._siftdown_max(li, 0, len(li) - 1)
	print(*final[1:])
t = int(input())
for i in range(t):
	solve()


from heapq import heappush, heapify, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	q = [[-n, 0]]
	heapify(q)
	for i in range(1, n + 1):
		(length, start) = heappop(q)
		end = start - length - 1
		mid = (start + end) // 2
		a[mid] = i
		if mid - start >= 0:
			heappush(q, [start - mid, start])
		if end - mid >= 0:
			heappush(q, [mid - end, mid + 1])
	print(*a)


from heapq import heappush, heappop
res = ['' for i in range(2 * 10 ** 5)]
tc = int(input())
while tc > 0:
	n = int(input())
	q = [(~n, 1, n)]
	step = 0
	while q:
		(d, l, r) = heappop(q)
		d = ~d
		mid = (l + r) // 2
		step += 1
		res[mid - 1] = str(step)
		if l < mid:
			heappush(q, (~(mid - l), l, mid - 1))
		if mid < r:
			heappush(q, (~(r - mid), mid + 1, r))
	print(' '.join(res[:n]))
	tc -= 1


import os
import sys
from io import BytesIO, IOBase

def main():

	def order(start, end):
		m = start + end
		if m % 2 == 0:
			mid = (m - 1) // 2
		else:
			mid = m // 2
		ord.append((end - start, start, mid))
		if start < mid:
			order(start, mid)
		if mid + 1 < end:
			order(mid + 1, end)
	for _ in range(int(input())):
		n = int(input())
		arr = [0] * n
		ord = []
		order(0, n)
		ord.sort(key=lambda x: (-x[0], x[1]))
		for i in range(len(ord)):
			arr[ord[i][2]] = i + 1
		print(*arr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import heapq
import sys
import math as mt
t = int(input())
for __ in range(t):
	n = int(input())
	a = [0] * (n + 1)
	curr = 1
	q = [(-1 * n, 1, n)]
	while curr <= n:
		(l, st, end) = heapq.heappop(q)
		mid = (st + end) // 2
		a[mid] = curr
		curr += 1
		if mid + 1 <= end:
			heapq.heappush(q, (-1 * (end - mid - 1), mid + 1, end))
		if st <= mid - 1:
			heapq.heappush(q, (-1 * (mid - st - 1), st, mid - 1))
	print(*a[1:])


def solve():
	n = int(input())
	small = n - 1
	large = n
	indexes = [(0, True)]
	ans = [0 for i in range(n)]
	x = 1
	while large > 2:
		new_indexes = []
		large_indexes = []
		small_indexes = []
		for (i, is_large) in indexes:
			if is_large:
				large_indexes.append(i + (large - 1) // 2)
				if large % 2 == 0:
					new_indexes.append((i, False))
					new_indexes.append((i + (large - 1) // 2 + 1, True))
				else:
					new_indexes.append((i, True))
					new_indexes.append((i + (large - 1) // 2 + 1, True))
			elif small > 0:
				small_indexes.append(i + (small - 1) // 2)
				if small % 2 == 0:
					new_indexes.append((i, False))
					new_indexes.append((i + (small - 1) // 2 + 1, True))
				else:
					new_indexes.append((i, False))
					new_indexes.append((i + (small - 1) // 2 + 1, False))
		for i in large_indexes:
			ans[i] = x
			x += 1
		for i in small_indexes:
			ans[i] = x
			x += 1
		indexes = new_indexes
		small = (small + large - 2) // 4
		large = small + 1
	if large == 2:
		for (i, is_large) in indexes:
			if is_large:
				ans[i] = x
				x += 1
		for (i, is_large) in indexes:
			if is_large:
				ans[i + 1] = x
			else:
				ans[i] = x
			x += 1
	elif large == 1:
		for (i, is_large) in indexes:
			if is_large:
				ans[i] = x
				x += 1
	print(' '.join(map(str, ans)))
t = int(input())
for tc in range(t):
	solve()


from bisect import insort_left
t = int(input())
for _ in range(t):
	n = int(input())
	li = [[] for _ in range(n + 1)]
	li[n] = [0]
	ans = [None] * n
	ind = 1
	for i in range(n, 0, -1):
		if len(li[i]) == 0:
			continue
		for j in li[i]:
			ans[j + (i - 1) // 2] = ind
			if i > 1:
				insort_left(li[(i - 1) // 2], j)
				insort_left(li[i // 2], j + (i - 1) // 2 + 1)
			ind += 1
	print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq
testcases = int(input())
for j in range(testcases):
	n = int(input())
	ordered = [0] * n
	segments = [0]
	dict1 = {0: [0]}
	for s in range(n):
		ind = heapq.heappop(segments)
		l = heapq.heappop(dict1[ind])
		r = l + n - 1 - ind
		ordered[(l + r) // 2] = s + 1
		if l != r:
			mid = (l + r) // 2
			if mid - 1 >= l:
				val1 = (l, mid - 1)
				if not n - 1 - (mid - 1 - l) in dict1:
					dict1[n - 1 - (mid - 1 - l)] = [l]
				else:
					heapq.heappush(dict1[n - 1 - (mid - 1 - l)], l)
				heapq.heappush(segments, n - 1 - (mid - 1 - l))
			if mid + 1 <= r:
				val2 = (mid + 1, r)
				if not n - 1 - (r - 1 - mid) in dict1:
					dict1[n - 1 - (r - 1 - mid)] = [mid + 1]
				else:
					heapq.heappush(dict1[n - 1 - (r - 1 - mid)], mid + 1)
				heapq.heappush(segments, n - 1 - (r - 1 - mid))
	ordered = [str(k) for k in ordered]
	print(' '.join(ordered))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq
for i in range(int(input())):
	n = int(input())
	q = [(-n, 0, n - 1)]
	heapq.heapify(q)
	cur = 1
	a = [0] * n
	while cur <= n:
		(l, s, e) = heapq.heappop(q)
		ind = (s + e) // 2
		a[ind] = cur
		cur += 1
		heapq.heappush(q, (s - ind, s, ind - 1))
		heapq.heappush(q, (ind - e, ind + 1, e))
	print(*a, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	if n == 1:
		print(1)
	elif n == 2:
		print(1, 2)
	else:
		n2 = n // 2
		segs = [[] for i in range(n2 + 1)]
		ans = [0] * n
		ans[n2 + n % 2 - 1] = 1
		segs[n2 - (1 - n % 2) - 1] += [0]
		segs[n2 - 1] += [n2 + n % 2]
		num = 2
		for i in range(n2, 1, -1):
			segs[i].sort()
			for j in segs[i]:
				n = i + 1
				n2 = n // 2
				beg = j
				ans[beg + n2 + n % 2 - 1] = num
				segs[n2 - (1 - n % 2) - 1] += [beg]
				segs[n2 - 1] += [beg + n2 + n % 2]
				num += 1
		segs[1].sort()
		for i in segs[1]:
			segs[0] += [i + 1]
			ans[i] = num
			num += 1
		segs[0].sort()
		for i in segs[0]:
			ans[i] = num
			num += 1
		print(' '.join(map(str, ans)))


from heapq import heappop, heappush
t = int(input())
for _ in range(t):
	n = int(input())
	num = [0] * n
	cnt = 0
	queue = [(1 - n, 0, n - 1)]
	while queue:
		cnt += 1
		r = heappop(queue)
		if r[2] - r[1] == 0:
			num[r[1]] = cnt
		else:
			num[(r[1] + r[2]) // 2] = cnt
			a = (r[1] - ((r[1] + r[2]) // 2 - 1), r[1], (r[1] + r[2]) // 2 - 1)
			b = ((r[1] + r[2]) // 2 + 1 - r[2], (r[1] + r[2]) // 2 + 1, r[2])
			if (r[1] + r[2]) // 2 - 1 - r[1] >= 0:
				heappush(queue, a)
			if r[2] - ((r[1] + r[2]) // 2 + 1) >= 0:
				heappush(queue, b)
	print(*num)


from heapq import *
t = int(input())
ans = []
for s in range(t):
	n = int(input())
	heap = [(-n, (0, n - 1))]
	heapify(heap)
	arr = [0] * n
	i = 1
	while i <= n:
		(m, (l, r)) = heappop(heap)
		mid = (l + r) // 2
		arr[mid] = i
		heappush(heap, (l + 1 - mid, (l, mid - 1)))
		heappush(heap, (mid + 1 - r, (mid + 1, r)))
		i += 1
	ans.append(arr)
for it in ans:
	print(*it, sep=' ')


def ri():
	return int(input())

def ria():
	return list(map(int, input().split()))

def ia_to_s(a):
	return ' '.join([str(s) for s in a])
import heapq

class Range(object):

	def __init__(self, left, right):
		self.left = left
		self.right = right

	def __repr__(self):
		return f'Range: [{self.left},{self.right})'

	def __lt__(self, other):
		this_len = self.right - self.left
		other_len = other.right - other.left
		if this_len == other_len:
			return self.left < other.left
		else:
			return this_len > other_len

def solve(n):
	a = [0] * n
	ranges = [Range(0, n)]
	heapq.heapify(ranges)
	iteration = 1
	while len(ranges) > 0:
		r = heapq.heappop(ranges)
		i = (r.left + r.right - 1) // 2
		a[i] = iteration
		if i > r.left:
			heapq.heappush(ranges, Range(r.left, i))
		if r.right > i + 1:
			heapq.heappush(ranges, Range(i + 1, r.right))
		iteration += 1
	return a

def main():
	for _ in range(ri()):
		n = ri()
		print(ia_to_s(solve(n)))
main()


import heapq

def solve(n):
	h = [(-n, 0, n - 1)]
	sol = [0] * n
	curr = 1
	while h:
		(_, l, r) = heapq.heappop(h)
		mid = l + (r - l) // 2
		if l <= mid - 1:
			heapq.heappush(h, (l - mid + 1, l, mid - 1))
		if r >= mid + 1:
			heapq.heappush(h, (mid + 1 - r, mid + 1, r))
		sol[mid] = curr
		curr += 1
	return sol
t = int(input())
for _ in range(t):
	n = int(input())
	print(' '.join(map(str, solve(n))))


from heapq import *
T = int(input())
for tt in range(T):
	n = int(input())
	ans = [0 for i in range(n + 1)]
	pq = []
	heappush(pq, (-n, 1))
	for i in range(1, n + 1):
		(sz, ind) = heappop(pq)
		sz = -sz
		(l, r) = (ind, ind + sz - 1)
		if sz % 2 == 1:
			ans[(l + r) // 2] = i
			heappush(pq, (-(sz // 2), (l + r) // 2 + 1))
			heappush(pq, (-(sz // 2), l))
		else:
			ans[(l + r - 1) // 2] = i
			heappush(pq, (-(sz // 2), (l + r - 1) // 2 + 1))
			heappush(pq, (-(sz // 2 - 1), l))
	print(' '.join(map(str, ans[1:])))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def binsrh(l, h):
	if l > h:
		return
	c = (l + h) // 2
	myh.append((h - l + 1, -c))
	if l == h:
		return
	if (h - l + 1) % 2 == 0:
		binsrh(c + 1, h)
		binsrh(l, c - 1)
	else:
		binsrh(l, c - 1)
		binsrh(c + 1, h)
cases = int(input())
for t in range(cases):
	n = int(input())
	a = [0] * n
	myh = []
	binsrh(0, n - 1)
	myh = sorted(sorted(myh, key=lambda x: x[1], reverse=True), reverse=True)
	c = 1
	for (i, j) in myh:
		a[-j] = c
		c += 1
	print(*a)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop, heapify
import math
import io
import os
import math
import bisect
from queue import Queue

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = [0] * n
	q = []
	heappush(q, [-n, -n, -n + 1])
	curr = 1
	while len(q) > 0:
		(c, a, b) = heappop(q)
		(c, a, b) = (-c, -a, -b)
		a = n - a
		if b - a + 1 & 1:
			l[(b + a) // 2] = curr
			curr += 1
			if -1 + (b + a) // 2 >= a:
				heappush(q, [1 - (b + a) // 2 + a, -n + a, 1 - (b + a) // 2])
			if 1 + (b + a) // 2 <= b:
				heappush(q, [1 + (b + a) // 2 - b, -n + 1 + (b + a) // 2, -b])
		else:
			l[(b + a - 1) // 2] = curr
			curr += 1
			if -1 + (b + a - 1) // 2 >= a:
				heappush(q, [1 - (b + a - 1) // 2 + a, -n + a, 1 - (b + a - 1) // 2])
			if 1 + (b + a - 1) // 2 <= b:
				heappush(q, [-b + 1 + (b + a - 1) // 2, -n + 1 + (b + a - 1) // 2, -b])
	print(*l)


def order(i_i, i_f):
	m = i_i + i_f
	if m % 2 == 0:
		mid = (m - 1) // 2
	else:
		mid = m // 2
	ord.append((i_f - i_i, i_i, mid))
	if i_i < mid:
		order(i_i, mid)
	if mid + 1 < i_f:
		order(mid + 1, i_f)
for _ in range(int(input())):
	n = int(input())
	arr = [0] * n
	ord = []
	order(0, n)
	ord.sort(key=lambda x: (-x[0], x[1]))
	for i in range(len(ord)):
		arr[ord[i][2]] = i + 1
	print(*arr)


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def func(a):
	return [a[1] - a[0]]

def solve():
	n = int(inp())
	a = []
	if n == 1:
		print(1)
	elif n == 2:
		print(1, 2)
	else:
		k = 1
		while 2 ** k <= n:
			k += 1
		k = 2 ** k
		for i in range(0, k + 1):
			if i == 1:
				a.append([1, n])
				continue
			a.append([0, 0])
		f = 0
		for i in range(1, k + 1):
			if a[i][0] == a[i][1]:
				continue
			if (a[i][1] - a[i][0] + 1) % 2 == 1:
				temp = (a[i][0] + a[i][1]) // 2
			else:
				temp = (a[i][0] + a[i][1] - 1) // 2
			if a[i][0] <= temp - 1:
				a[2 * i] = [a[i][0], temp - 1]
			if temp + 1 <= a[i][1]:
				a[2 * i + 1] = [temp + 1, a[i][1]]
		a = sorted(a, key=func)[::-1]
		final = []
		for i in range(0, len(a)):
			if a[i][0] != 0 and a[i][1] != 0:
				final.append(a[i])
		ok = []
		temp = []
		for i in range(0, len(final)):
			if i == 0:
				temp.append(final[i])
				diff = final[i][1] - final[i][0]
			elif final[i][1] - final[i][0] == diff:
				temp.append(final[i])
			else:
				temp = sorted(temp)
				ok += temp
				temp = []
				diff = final[i][1] - final[i][0]
				temp.append(final[i])
			if i == len(final) - 1:
				temp = sorted(temp)
				ok += temp
		ans = [0] * (n + 1)
		for i in range(1, n + 1):
			if (ok[i - 1][1] - ok[i - 1][0] + 1) % 2 == 1:
				ans[(ok[i - 1][0] + ok[i - 1][1]) // 2] = i
			else:
				ans[(ok[i - 1][0] + ok[i - 1][1] - 1) // 2] = i
		print(*ans[1:])
testcase(int(inp()))


t = int(input())
for i in range(t):
	n = int(input())
	d = {n: {0: n - 1}}
	l = [0] * n
	m = n
	l1 = [n]
	k = 0
	v = 0
	while len(d) > 0:
		l2 = []
		if m == 0:
			break
		l3 = sorted(d[m])
		for v1 in l3:
			j = (v1, d[m][v1])
			k += 1
			if (j[1] - j[0] + 1) % 2 == 0:
				l[(j[0] + j[1] - 1) // 2] = k
				c = (j[0] + j[1] - 1) // 2
			else:
				l[(j[0] + j[1]) // 2] = k
				c = (j[0] + j[1]) // 2
			if j[1] - c > 0:
				if j[1] - c not in d:
					d[j[1] - c] = {}
					l1.append(j[1] - c)
			if c - j[0] > 0:
				if c - j[0] not in d:
					d[c - j[0]] = {}
					l1.append(c - j[0])
			if j[1] - c > 0:
				d[j[1] - c][c + 1] = j[1]
			if c - j[0] > 0:
				d[c - j[0]][j[0]] = c - 1
		v += 1
		if v < len(l1):
			m = l1[v]
		else:
			m = 0
	print(*l)


from heapq import heappush, heappop

def main():
	for test in range(int(input())):
		n = int(input())
		print(*solution(n))

def solution(n):
	act = 1
	arr = [0] * n
	segs = [(-n, (0, n - 1))]
	while segs:
		mx = heappop(segs)
		(l, r) = mx[1]
		mid = (l + r) // 2 if (r - l) % 2 == 0 else (l + r - 1) // 2
		arr[mid] = act
		act += 1
		if r - l + 1 == 1:
			continue
		seg2 = (-(r - mid), (mid + 1, r))
		heappush(segs, seg2)
		if r - l + 1 == 2:
			continue
		seg1 = (-(mid - l), (l, mid - 1))
		heappush(segs, seg1)
	return arr
main()


from heapq import heappop, heappush
for i in range(int(input())):
	n = int(input())
	arr = [0] * n
	hp = [(-n, (0, n - 1))]
	for j in range(1, n + 1):
		(left, right) = heappop(hp)[1]
		if (right - left + 1) % 2 == 1:
			m = (left + right) // 2
		else:
			m = (left + right - 1) // 2
		arr[m] = j
		if left <= m - 1:
			heappush(hp, (-(m - 1 - left), (left, m - 1)))
		if m + 1 <= right:
			heappush(hp, (-(right - m - 1), (m + 1, right)))
	print(*arr)


import sys
input = sys.stdin.readline
import heapq
import copy
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

class Node:

	def _init_(self, val):
		self.data = val
		self.left = None
		self.right = None

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def pr_list(a):
	print(*a, sep=' ')

def find_permut(hashm, l):
	ans = 1
	total = math.factorial(l)
	for i in hashm:
		if i != 0:
			ans = ans * math.factorial(i)
	return int(total / ans)

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	for test in range(tests):
		n = inp()
		ans = [0 for i in range(n)]
		heap = [[-1 * n, 0, n - 1]]
		heapq.heapify(heap)
		k = 1
		while heap != []:
			[val, i, j] = heapq.heappop(heap)
			mid = i + int((j - i) / 2)
			ans[mid] = k
			k = k + 1
			if (j - i + 1) % 2 != 0 and j != i:
				heapq.heappush(heap, [-1 * (mid - i), i, mid - 1])
				heapq.heappush(heap, [-1 * (j - mid), mid + 1, j])
			elif (j - i + 1) % 2 == 0 and j - i != 1:
				heapq.heappush(heap, [-1 * (mid - i), i, mid - 1])
				heapq.heappush(heap, [-1 * (j - mid), mid + 1, j])
			elif j - i == 1:
				heapq.heappush(heap, [-1 * (j - mid), mid + 1, j])
		pr_list(ans)
main()


import heapq
t = int(input())
for i in range(t):
	n = int(input())
	a = [0 for _ in range(n)]
	h = [-1 * (n * (2 * 10 ** 5) + (2 * 10 ** 5 - 1))]
	heapq.heapify(h)
	for step_number in range(1, n + 1):
		seg = heapq.heappop(h) * -1
		start_idx = 2 * 10 ** 5 - 1 - seg % (2 * 10 ** 5)
		length = seg // (2 * 10 ** 5)
		l = start_idx
		r = start_idx + length - 1
		if length % 2 == 0:
			a[(l + r - 1) // 2] = step_number
			heapq.heappush(h, -1 * ((length // 2 - 1) * (2 * 10 ** 5) + 2 * 10 ** 5 - 1 - l))
			heapq.heappush(h, -1 * (length // 2 * (2 * 10 ** 5) + 2 * 10 ** 5 - 1 - (length // 2 + l)))
		elif length > 1:
			a[(l + r) // 2] = step_number
			heapq.heappush(h, -1 * (length // 2 * (2 * 10 ** 5) + 2 * 10 ** 5 - 1 - l))
			heapq.heappush(h, -1 * (length // 2 * (2 * 10 ** 5) + 2 * 10 ** 5 - 1 - (l + length // 2 + 1)))
		else:
			a[l] = step_number
	print(*a)


from heapq import *
import sys
input = sys.stdin.readline
for _ in range(int(input().rstrip())):
	n = int(input().rstrip())
	data = [0] * n
	hq = [(-n, 0, n - 1)]
	i = 1
	while len(hq) != 0:
		(_, L, R) = heappop(hq)
		mid = (L + R) // 2
		data[mid] = i
		i += 1
		if L < mid:
			heappush(hq, (L - mid, L, mid - 1))
		if mid < R:
			heappush(hq, (mid - R, mid + 1, R))
	print(*data)


from pprint import pprint
import sys
input = sys.stdin.readline
import collections
q = int(input())
import heapq
for _ in range(q):
	n = int(input())
	res = [0] * (n + 10)
	h = [(-n, 1, n)]
	heapq.heapify(h)
	for i in range(n):
		(len, l, r) = heapq.heappop(h)
		len = -len
		if (r - l + 1) % 2 == 1:
			a = (l + r) // 2
		else:
			a = (l + r - 1) // 2
		res[a] = i + 1
		if a - 1 >= l:
			heapq.heappush(h, [-(a - l), l, a - 1])
		if a + 1 <= r:
			heapq.heappush(h, [-(r - a), a + 1, r])
	print(' '.join(list(map(str, res[1:n + 1]))))


from collections import deque
import heapq
for nt in range(int(input())):
	n = int(input())
	if n == 1:
		print(1)
		continue
	if n == 2:
		print(1, 2)
		continue
	if True:
		ans = [-1] * n
		q2 = []
		ans[(n + 1) // 2 - 1] = 1
		q2.append([-(n - ((n + 1) // 2 + 1) + 1), (n + 1) // 2 + 1, n])
		q2.append([-((n + 1) // 2) + 1, 1, (n + 1) // 2 - 1])
		heapq.heapify(q2)
		flag = 1
		k = 2
		while len(q2) != 0:
			group = heapq.heappop(q2)
			group[0] = -1 * group[0]
			if group[0] == 1:
				ans[group[1] - 1] = k
			elif group[0] == 2:
				ans[group[1] - 1] = k
				heapq.heappush(q2, [-1, group[1] + 1, group[2]])
			elif group[0] % 2:
				ans[group[1] + group[0] // 2 - 1] = k
				heapq.heappush(q2, [-(group[0] // 2), group[1], group[1] + group[0] // 2 - 1])
				heapq.heappush(q2, [-(group[0] // 2), group[1] + group[0] // 2 + 1, group[2]])
			else:
				ans[group[1] + group[0] // 2 - 2] = k
				heapq.heappush(q2, [-(group[0] // 2) + 1, group[1], group[1] + group[0] // 2 - 2])
				heapq.heappush(q2, [-(group[0] // 2), group[1] + group[0] // 2, group[2]])
			k += 1
		for i in range(n):
			if ans[i] == -1:
				ans[i] = k
				k += 1
		print(*ans)


import sys
input = sys.stdin.readline
import heapq
for _ in range(int(input())):
	n = int(input())
	arr = [0] * n
	heap = []
	heap.append((-n, 0))
	current = 1
	while heap:
		(length, index) = heapq.heappop(heap)
		length = -length
		if length == 0:
			continue
		if length & 1:
			arr[index + length // 2] = current
			current += 1
			heapq.heappush(heap, (-((length - 1) // 2), index))
			heapq.heappush(heap, (-((length - 1) // 2), index + (length - 1) // 2 + 1))
		else:
			arr[index + length // 2 - 1] = current
			current += 1
			heapq.heappush(heap, (-((length - 1) // 2), index))
			heapq.heappush(heap, (-(length // 2), index + length // 2))
	for i in range(len(arr)):
		print(arr[i], end=' ')
	print()


import heapq
for i in range(int(input())):
	n = int(input())
	ans = [0] * n
	q = [(n, 0, n - 1)]
	now = 0
	while q:
		now += 1
		(le, l, r) = heapq.heappop(q)
		ans[(l + r) // 2] = now
		m = (l + r) // 2
		if l == r:
			continue
		if m > l:
			heapq.heappush(q, (-(m - l), l, m - 1))
		if r > m:
			heapq.heappush(q, (-(r - m), m + 1, r))
	print(' '.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		ans = [None] * n
		if n == 1:
			print(1)
			continue
		minHeap = [(-n, 0)]
		cnt = 1
		while minHeap and cnt <= n:
			temp = heapq.heappop(minHeap)
			length = -temp[0]
			pos = temp[1]
			if length == 1:
				ans[pos] = cnt
			elif length == 2:
				ans[pos] = cnt
				heapq.heappush(minHeap, (-1, pos + 1))
			elif length % 2:
				ans[pos + length // 2] = cnt
				heapq.heappush(minHeap, (-(length - 1) // 2, pos))
				heapq.heappush(minHeap, (-(length - 1) // 2, pos + length // 2 + 1))
			else:
				ans[pos + length // 2 - 1] = cnt
				heapq.heappush(minHeap, (-(length // 2) + 1, pos))
				heapq.heappush(minHeap, (-(length // 2), pos + length // 2))
			cnt += 1
		for i in ans:
			print(i, end=' ')
		if _ < t - 1:
			print('')
	return
main()


t = int(input())
import heapq

def make_tuple(l, r, n):
	return (-(n + 1) * (r - l + 1) + l, l, r)
for _ in range(t):
	n = int(input())
	H = []
	heapq.heapify(H)
	ans = [0] * n
	heapq.heappush(H, make_tuple(0, n - 1, n))
	for i in range(n):
		(_, l, r) = heapq.heappop(H)
		j = (l + r) // 2
		ans[j] = i + 1
		if l <= j - 1 and j - 1 >= 0:
			heapq.heappush(H, make_tuple(l, j - 1, n))
		if j + 1 <= r and j + 1 <= n - 1:
			heapq.heappush(H, make_tuple(j + 1, r, n))
	print(*ans)


def main():
	import sys, math
	from heapq import heapify, heappush, heappop
	from collections import defaultdict as dd, deque, Counter

	def data():
		return sys.stdin.readline().strip()

	def mdata():
		return list(map(int, data().split()))

	def out(*var, end='\n'):
		sys.stdout.write('\n'.join(map(str, var)) + end)
	sys.setrecursionlimit(100000)
	INF = float('inf')
	mod = int(1000000000.0) + 7

	def recur(l, r, ans):
		global cnt
		if l > r:
			return
		if l == r:
			ans.append([1, l])
			return
		mid = (l + r) // 2
		ans.append([r - l + 1, mid])
		recur(l, mid - 1, ans)
		recur(mid + 1, r, ans)
	for t in range(int(data())):
		n = int(data())
		global cnt
		cnt = 1
		ans = []
		recur(0, n - 1, ans)
		ans.sort(key=lambda x: x[1])
		ans.sort(key=lambda x: x[0], reverse=True)
		ans1 = [0] * n
		for i in range(n):
			ans1[ans[i][1]] = i + 1
		print(*ans1)
main()


from sys import setrecursionlimit
from collections import deque
import heapq
import functools
setrecursionlimit(2 * 10 ** 5 + 1)

def rec(array):
	Min_heap = [[-1 * (len(array) - 1), 0, len(array) - 1]]
	heapq.heapify(Min_heap)
	a = 1
	while Min_heap:
		[d, l, r] = heapq.heappop(Min_heap)
		if l > r:
			continue
		m = (l + r) // 2
		array[m] = a
		a += 1
		if l >= r:
			continue
		heapq.heappush(Min_heap, [-1 * (m - 1 - l), l, m - 1])
		heapq.heappush(Min_heap, [-1 * (r - 1 - m), m + 1, r])
	return array
for _ in range(int(input())):
	n = int(input())
	ans = rec([0] * n)
	print(*ans)


from heapq import *
for _ in range(int(input())):
	n = int(input())
	(pq, arr, cur) = ([(-n, 1, n)], [0] * n, 1)
	heapify(pq)
	while len(pq) > 0:
		(sz, start, end) = heappop(pq)
		mid = start + end >> 1
		if arr[mid - 1] == 0:
			arr[mid - 1] = cur
			cur += 1
		if mid - 1 >= start:
			heappush(pq, (start - mid, start, mid - 1))
		if end >= mid + 1:
			heappush(pq, (mid - end, mid + 1, end))
	print(*arr)


def bins(l, r):
	global c, count
	if l > r:
		return
	mid = (l + r) // 2
	c.append([r - l, -1 * l])
	bins(l, mid - 1)
	bins(mid + 1, r)
t = int(input())
for _ in range(t):
	count = 0
	c = []
	n = int(input())
	a = [0] * n
	bins(0, n - 1)
	c.sort(reverse=True)
	for i in c:
		ans = i[0] // 2 - i[1]
		a[ans] = count + 1
		count += 1
	print(*a)


import heapq as hq
for _ in range(int(input())):
	n = int(input())
	h = [[-n, 1, n]]
	a = [0] * (n + 1)
	i = 1
	while h:
		(len, l, r) = hq.heappop(h)
		mid = (l + r) // 2
		if r > mid:
			hq.heappush(h, [-(r - mid), mid + 1, r])
		if l < mid:
			hq.heappush(h, [-(mid - l), l, mid - 1])
		a[mid] = i
		i += 1
	print(*a[1:n + 1])


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0 for i in range(n)]
	j = 1
	q = [(-1 * n, 0, n - 1)]
	heapq.heapify(q)
	while len(q) > 0:
		s = heapq.heappop(q)
		if abs(s[0]) % 2 == 1:
			mid = (s[2] + s[1]) // 2
			a[mid] = j
			if mid - s[1] >= 1:
				length = -mid + s[1]
				heapq.heappush(q, (length, s[1], mid - 1))
			if s[2] - mid >= 1:
				length = mid - s[2]
				heapq.heappush(q, (length, mid + 1, s[2]))
		else:
			mid = (s[2] + s[1] - 1) // 2
			a[mid] = j
			if mid - s[1] >= 1:
				length = -mid + s[1]
				heapq.heappush(q, (length, s[1], mid - 1))
			if s[2] - mid >= 1:
				length = mid - s[2]
				heapq.heappush(q, (length, mid + 1, s[2]))
		j += 1
	print(' '.join(map(str, a)))


import heapq
a = [0] * 2 * 10 ** 5
for _ in range(int(input())):
	n = int(input())
	h = [(-n, 0, n - 1)]
	for i in range(1, n + 1):
		(v, l, r) = heapq.heappop(h)
		m = (l + r) // 2
		a[m] = i
		(lr, rl) = (m - 1, m + 1)
		if l <= lr:
			heapq.heappush(h, (-(lr - l), l, lr))
		if rl <= r:
			heapq.heappush(h, (-(r - rl), rl, r))
	print(' '.join(map(str, a[:n])))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = [0] * n
		z = [[-n, 0]]
		heapify(z)
		i = 0
		for i in range(1, n + 1):
			(le, l) = heappop(z)
			r = -le + l - 1
			m = (l + r) // 2
			a[m] = i
			heappush(z, [-(m - l), l])
			heappush(z, [-(r - m), m + 1])
		print(*a)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


def psh(a, b):
	if a > b:
		return
	mid = (a + b) // 2
	c.append([b - a, -1 * a])
	psh(mid + 1, b)
	psh(a, mid - 1)
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	(c, a) = ([], [0] * n)
	psh(0, n - 1)
	c.sort(reverse=True)
	for i in range(n):
		d = c[i][0] // 2 - c[i][1]
		a[d] = i + 1
	print(*a)


import os
import sys
from io import BytesIO, IOBase
from heapq import heappush, heappop

def solution(n):
	arr = [0] * (n + 1)
	heap = []
	heappush(heap, (-n, (1, n)))
	(l, r) = (0, n)
	i = 1
	while True:
		cur = heappop(heap)
		(l, r) = cur[1]
		if r - l + 1 & 1:
			arr[(l + r) // 2] = i
			mid = (l + r) // 2
		else:
			arr[(l + r - 1) // 2] = i
			mid = (l + r - 1) // 2
		if i == n:
			break
		heappush(heap, (-(mid - 1 - l + 1), (l, mid - 1)))
		heappush(heap, (-(r - (mid + 1) + 1), (mid + 1, r)))
		i += 1
	write(*arr[1:n + 1])

def main():
	for _ in range(r_int()):
		n = r_int()
		solution(n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]
t = int(input())
for i in range(t):
	n = inputnum()
	ans = [-1] * n
	heap = []
	heapq.heappush(heap, (-n, 0, n - 1))
	for i in range(n):
		(neg, l, r) = heapq.heappop(heap)
		mid = (r + l) // 2
		ans[mid] = i + 1
		if mid != l:
			heapq.heappush(heap, (-(mid - l), l, mid - 1))
		if mid != r:
			heapq.heappush(heap, (-(r - mid), mid + 1, r))
	print(*ans)


def fun(a, b):
	if a > b:
		return
	mid = (a + b) // 2
	temp.append((b - a, -mid))
	fun(mid + 1, b)
	fun(a, mid - 1)
for _ in range(int(input())):
	n = int(input())
	Ans = [0] * (n + 1)
	temp = []
	fun(1, n)
	temp.sort(reverse=True)
	t = 1
	for i in temp:
		Ans[abs(i[1])] = t
		t += 1
	print(*Ans[1:])


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def main():
	T = read_int()
	for _ in range(T):
		n = read_int()
		res = [0] * (n + 1)
		op = 1
		pq = [(-(n - 1), 1, n)]
		while pq:
			(_, l, r) = heapq.heappop(pq)
			m = (l + r) // 2 if (r - l + 1) % 2 == 1 else (l + r - 1) // 2
			res[m] = op
			if m - 1 >= l:
				heapq.heappush(pq, (-(m - 1 - l), l, m - 1))
			if m + 1 <= r:
				heapq.heappush(pq, (-(r - m - 1), m + 1, r))
			op += 1
		print(*res[1:], sep=' ')
main()


import heapq
from sys import stdin
input = stdin.readline
for Ti in range(int(input().strip())):
	n = int(input().strip())
	h = [(-n, 1, n)]
	a = [0] * n
	i = 1
	while h:
		(nlen, s, e) = heapq.heappop(h)
		mid = (s + e) // 2
		a[mid - 1] = i
		i += 1
		if mid > s:
			heapq.heappush(h, (s - mid, s, mid - 1))
		if e > mid:
			heapq.heappush(h, (mid - e, mid + 1, e))
	print(*a)


from heapq import heappush, heapify, heappop

def f(l, r):
	return -(r - l + 1)

def g(l, r):
	s = -f(l, r)
	if s % 2 == 0:
		return (l + r - 1) // 2
	return (l + r) // 2
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * (n + 1)
	h = []
	heapify(h)
	heappush(h, (f(1, n), (1, n)))
	i = 1
	pos = 0
	while h:
		(sum, (l, r)) = heappop(h)
		mid = g(l, r)
		arr[mid] = i
		i += 1
		if mid - 1 >= l:
			p = (f(l, mid - 1), (l, mid - 1))
			heappush(h, p)
		if mid + 1 <= r:
			q = (f(mid + 1, r), (mid + 1, r))
			heappush(h, q)
	print(' '.join((str(x) for x in arr[1:])))


import heapq
T = int(input())
while T > 0:
	n = int(input())
	dic = {}
	res = [0] * n
	dic[n] = [[0, n - 1]]
	pq = [-n]
	for i in range(1, n + 1):
		x = -heapq.heappop(pq)
		(l, r) = heapq.heappop(dic[x])
		mid = (l + r) // 2
		res[mid] = i
		l1 = mid - l
		l2 = r - mid
		if l1 > 0:
			heapq.heappush(pq, -l1)
			if l1 not in dic:
				dic[l1] = [[l, mid - 1]]
			else:
				heapq.heappush(dic[l1], [l, mid - 1])
		if l2 > 0:
			heapq.heappush(pq, -l2)
			if l2 not in dic:
				dic[l2] = [[mid + 1, r]]
			else:
				heapq.heappush(dic[l2], [mid + 1, r])
	print(*res)
	T -= 1


import heapq

def main(n):
	ans = [0] * n
	i = 0
	j = n - 1
	h = [(i - j - 1, i, j)]
	heapq.heapify(h)
	cnt = 1
	while h:
		(len, x, y) = heapq.heappop(h)
		len = -len
		mid = (x + y) // 2
		ans[mid] = cnt
		if mid - x > 0:
			heapq.heappush(h, (x - mid, x, mid - 1))
		if y - mid > 0:
			heapq.heappush(h, (mid - y, mid + 1, y))
		cnt += 1
	print(*ans)
for _ in range(int(input())):
	n = int(input())
	main(n)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from heapq import heapify, heappush as hp, heappop as pop
t = int(input())
for i in range(t):
	n = int(input())
	pq = []
	heapify(pq)
	hp(pq, [-n, 0, n - 1])
	ans = [0] * n
	j = 1
	while len(pq):
		l = pop(pq)
		mid = (l[2] + l[1]) // 2
		ans[mid] = j
		if l[1] - mid < 0:
			l1 = [l[1] - mid, l[1], mid - 1]
			hp(pq, l1)
		if mid - l[2] < 0:
			l2 = [mid - l[2], mid + 1, l[2]]
			hp(pq, l2)
		j += 1
	print(*ans)


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)

class Segment:

	def __init__(self, l, r):
		self.left = l
		self.right = r

	def __lt__(self, other):
		lenS = self.right - self.left + 1
		lenO = other.right - other.left + 1
		if lenS == lenO:
			return self.left < other.left
		return lenS > lenO
for _ in range(int(f_input())):
	amount = int(f_input())
	mass = [0 for i in range(amount)]
	queue = [Segment(0, amount - 1)]
	i = 0
	while i < amount:
		(left, right) = (queue[i].left, queue[i].right)
		place = (left + right) // 2
		if left < place:
			queue.append(Segment(left, place - 1))
		if place < right:
			queue.append(Segment(place + 1, right))
		i += 1
	value = 1
	for i in sorted(queue):
		(left, right) = (i.left, i.right)
		place = (left + right) // 2
		mass[place] = value
		value += 1
	f_print(' '.join([str(i) for i in mass]) + '\n')


import heapq

class IntBox:

	def __init__(self):
		self.val = 1

class Range:

	def __init__(self, start, end):
		self.start = start
		self.end = end
		self.length = end - start

	def __lt__(self, other: 'Range'):
		if self.length == other.length:
			return self.start < other.start
		return self.length > other.length

def split(r: Range, a, i):
	center = (r.end + r.start - 1) // 2
	a[center] = i
	ranges = []
	if r.start < center:
		ranges.append(Range(r.start, center))
	if center + 1 < r.end:
		ranges.append(Range(center + 1, r.end))
	return ranges
for _ in range(int(input())):
	l = int(input())
	a = [0] * l
	ranges = [Range(0, l)]
	heapq.heapify(ranges)
	i = 1
	while ranges:
		m = heapq.heappop(ranges)
		for r in split(m, a, i):
			heapq.heappush(ranges, r)
		i += 1
	print(*a)


import math
from collections import *
import sys
from functools import reduce
import time
from itertools import groupby

def input():
	return sys.stdin.readline()

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)]
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1), (+1, +1), (+1, +0), (+1, -1), (+0, +1)]
CAPS_ALPHABETS = {chr(i + ord('A')): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + ord('a')): i for i in range(26)}
INF = float('inf')
S34t = time.time()
for _testcases_ in range(int(input())):
	n = int(input())
	li = [(1, n)]
	i = 0
	while i < len(li):
		(l, r) = li[i]
		if l != r:
			if r - l + 1 & 1:
				m = (l + r) // 2
			else:
				m = (l + r - 1) // 2
			if m - 1 >= l:
				li.append((l, m - 1))
			if m + 1 <= r:
				li.append((m + 1, r))
		i += 1
	assert len(li) == n
	li = sorted(li, key=lambda x: (x[0] - x[1], x[0]))
	ans = [0] * (n + 1)
	for i in range(n):
		(l, r) = li[i]
		if r - l + 1 & 1:
			m = (l + r) // 2
		else:
			m = (l + r - 1) // 2
		ans[m] = i + 1
	print(*ans[1:])
S34p = time.time()


from collections import deque
from heapq import heappush, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	i = 1
	heap = [(n - 1, (1, n))]
	result = [0] * n
	while heap:
		(size, (curr_r, curr_l)) = heappop(heap)
		idx = curr_l + curr_r
		summed = curr_l - curr_r + 1
		if summed % 2:
			idx = (curr_l + curr_r) // 2
			result[idx - 1] = i
			i += 1
			if curr_r <= idx - 1:
				heappush(heap, (-(idx - 1 - curr_r), (curr_r, idx - 1)))
			if curr_l >= idx + 1:
				heappush(heap, (-(curr_l - idx - 1), (idx + 1, curr_l)))
		else:
			idx = (curr_l + curr_r - 1) // 2
			result[idx - 1] = i
			i += 1
			if curr_l >= idx + 1:
				heappush(heap, (-(curr_l - idx - 1), (idx + 1, curr_l)))
			if curr_r <= idx - 1:
				heappush(heap, (-(idx - 1 - curr_r), (curr_r, idx - 1)))
	print(' '.join(map(str, result)))


def solve(l, r):
	if l > r:
		return
	mid = (l + r) // 2
	if r - l in ls:
		ls[r - l].append(mid)
	else:
		ls[r - l] = [mid]
		ch.append(r - l)
	solve(l, mid - 1)
	solve(mid + 1, r)
for _ in range(int(input())):
	n = int(input())
	ls = {}
	ch = []
	ans = [0] * n
	solve(1, n)
	ch = sorted(ch, reverse=True)
	val = 1
	for i in ch:
		h = ls[i]
		h.sort()
		for j in h:
			ans[j - 1] = val
			val += 1
	print(*ans)


from collections import defaultdict
from sys import stdin

def put():
	return map(int, stdin.readline().split())
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * n
	s = [(0, n - 1)]
	ans = []
	while s:
		(l, r) = s.pop()
		m = (l + r) // 2
		ans.append((-(r - l + 1), l, m))
		if l <= m - 1:
			s.append((l, m - 1))
		if m + 1 <= r:
			s.append((m + 1, r))
	ans.sort()
	k = 1
	for (j, q, i) in ans:
		a[i] = k
		k += 1
	print(*a)


import io, os
from heapq import *

def ri():
	return int(input().strip())

def rl():
	return list(map(int, input().strip().split()))

def Solve():
	n = ri()
	a = [0] * (n + 1)
	q = [(-n, 1, n)]
	for i in range(n):
		x = heappop(q)
		(l, r) = (x[1], x[2])
		if (r - l + 1) % 2 == 1:
			mid = (l + r) // 2
		else:
			mid = (l + r - 1) // 2
		a[mid] = i + 1
		if l <= mid - 1:
			heappush(q, (-(mid - 1 - l + 1), l, mid - 1))
		if mid + 1 <= r:
			heappush(q, (-(r - (mid + 1) + 1), mid + 1, r))
	for i in range(1, n + 1):
		print(a[i], end=' ')
	print()
T = ri()
while T:
	T -= 1
	Solve()


import heapq
t = int(input())
for ii in range(t):
	n = int(input())
	h = []
	heapq.heapify(h)
	h.append((-n, 0, n - 1))
	a = [0] * n
	k = 1
	while len(h) > 0:
		(siz, l, r) = heapq.heappop(h)
		mid = l + (r - l) // 2
		a[mid] = k
		k += 1
		if r != mid:
			heapq.heappush(h, (mid - r, mid + 1, r))
		if l != mid:
			heapq.heappush(h, (l - mid, l, mid - 1))
	print(*a)


import heapq as hq
t = int(input())
for _ in range(t):
	n = int(input())
	l = [0 for _ in range(n)]
	h = [(-n, 0)]
	for i in range(n):
		(k, j) = hq.heappop(h)
		k = -k
		r = j + k - 1
		if (r - j + 1) % 2 == 0:
			mid = (j + r - 1) // 2
		else:
			mid = (j + r) // 2
		l[mid] = i + 1
		if k > 2:
			left = (-(mid - j), j)
			right = (-(k - (mid - j) - 1), mid + 1)
			hq.heappush(h, left)
			hq.heappush(h, right)
		elif k == 2:
			right = (-1, j + 1)
			hq.heappush(h, right)
	print(' '.join([str(x) for x in l]))


import atexit
import io
import sys
from collections import deque
from heapq import *
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__

def fun(a, b):
	if (b - a + 1) % 2 == 1:
		m = (b + a) // 2
	else:
		m = (b + a - 1) // 2
	return m
tc = int(input())
pur = fun
for zzz in range(tc):
	n = int(input())
	arr = []
	arr.append(0)
	for i in range(n):
		arr.append(0)
	dq1 = deque()
	dq2 = deque()
	dq1.append((1, n))
	while len(dq1) > 0:
		tem = dq1.popleft()
		dq2.append((-(tem[1] - tem[0]), tem[0], tem[1]))
		a = tem[0]
		b = tem[1]
		if a != b:
			m = pur(a, b)
			if a != m:
				dq1.append((a, m - 1))
			if b != m:
				dq1.append((m + 1, b))
	oww = []
	for ele in dq2:
		heappush(oww, ele)
	i = 1
	while len(oww) > 0:
		r = heappop(oww)
		d = pur(r[1], r[2])
		arr[d] = i
		i += 1
	yum = [str(i) for i in arr[1:]]
	print(' '.join(yum))


from bisect import bisect_right as br
for _ in range(int(input())):
	n = int(input())
	v = [0] * n
	if n % 2 == 0:
		v[n // 2 - 1] = 1
	else:
		v[n // 2] = 1
	if n:
		j = 2
		while j <= n:
			m = 0
			d = {}
			c = 0
			prev = 0
			for i in range(n):
				if v[i] == 0:
					c += 1
				else:
					if c >= m:
						m = c
						if c not in d:
							d[c] = [prev + (i - 1 - prev) // 2]
						else:
							d[c].append(prev + (i - 1 - prev) // 2)
					prev = i + 1
					c = 0
			if c >= m:
				m = c
				if c not in d:
					d[c] = [prev + (i - prev) // 2]
				else:
					d[c].append(prev + (i - prev) // 2)
			for x in d[m]:
				v[x] = j
				j += 1
	print(*v)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq
for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	(start, end) = (0, n - 1)
	length = end - start
	queue = [(length, start, end)]
	cur = 1
	while cur <= n:
		(length, start, end) = heapq.heappop(queue)
		mid = (start + end) // 2
		a[mid] = cur
		cur += 1
		heapq.heappush(queue, (-1 * (mid - 1 - start), start, mid - 1))
		heapq.heappush(queue, (-1 * (end - (mid + 1)), mid + 1, end))
	print(' '.join((str(k) for k in a)))


from heapq import heappush as hp, heappop as hpop
for t in range(int(input())):
	n = int(input())
	a = [0] * n
	h = []
	hp(h, (-n, (0, n - 1)))
	i = 1
	for i in range(1, n + 1):
		(s, (l, r)) = hpop(h)
		j = (r + l) // 2
		a[j] = i
		hp(h, (-(j - l), (l, j - 1)))
		hp(h, (-(r - j), (j + 1, r)))
	print(*a)


class Btree:
	l = []

	def shiftup(self, index):
		value = self.l[index]
		while index > 0:
			parent = index - 1 >> 1
			parentval = self.l[parent]
			if value < parentval:
				self.l[index] = parentval
				index = parent
				continue
			break
		self.l[index] = value

	def push(self, el):
		self.l.append(el)
		index = len(self.l) - 1
		self.shiftup(index)

	def pop(self):
		ans = self.l[0]
		value = self.l.pop()
		if self.l:
			index = 0
			sonl = 1
			totlen = len(self.l)
			while sonl < totlen:
				sonr = sonl + 1
				if sonr < totlen:
					if self.l[sonl] > self.l[sonr]:
						sonl = sonr
				self.l[index] = self.l[sonl]
				index = sonl
				sonl = 2 * index + 1
			self.l[index] = value
			self.shiftup(index)
		return ans

def tuplmk(a, b):
	return (a - 1 - b, a, b)

def ans(n):
	ans = [0 for i in range(n)]
	h = Btree()
	h.push(tuplmk(1, n))
	for el in range(1, n + 1):
		seq = h.pop()
		ind = (seq[1] + seq[2]) // 2
		ans[ind - 1] = el
		h.push(tuplmk(seq[1], ind - 1))
		h.push(tuplmk(ind + 1, seq[2]))
	return ' '.join([str(i) for i in ans])
t = int(input())
tlist = [0 for i in range(t)]
d = {}
for pset in range(t):
	n = int(input())
	tlist[pset] = n
	if n in d:
		print(d[n])
	else:
		answ = ans(n)
		d[n] = answ
		print(answ)