T = int(input()) import heapq def calc(N,M): ans = [0] * N ans[M-1] = 1 q = [] if M != 1: heapq.heappush(q,(-(M-1),0,-1,M-1)) if M != N: heapq.heappush(q,(-(N - M),N - 1,M-1,N)) for _ in range(N - 1): d,now,a,b = heapq.heappop(q) ans[now] = _ + 2 #print(d,now,a,b) if a != -1: if now - a == 1:pass else: u = a + (now - a) // 2 heapq.heappush(q,(-((now-a)//2),u,a,now)) if b != N: if b - now == 1:pass else: u = now + (b - now) // 2 heapq.heappush(q,(-((b-now)//2),u,now,b)) print(*ans) for _ in range(T): n,m = map(int,input().split()) calc(n,m)