from sys import stdin input = stdin.readline from heapq import heappush, heappop def cost(l, r): m = (l+r)//2 return m-(l-1) for _ in range(int(input())): N, M = map(int, input().split()) que = [] ans = [-1]*N ans[M-1] = 1 if 2 <= M: heappush(que, (-(M-1), 0, M-2)) if M < N: heappush(que, (-(N-M), M, N-1)) for i in range(2, N+1): _, l, r = heappop(que) if l == 0: ans[l] = i if l+1 <= r: heappush(que, (-cost(l+1, r), l+1, r)) elif r == N-1: ans[r] = i if l <= r-1: heappush(que, (-cost(l, r-1), l, r-1)) else: m = (l+r)//2 ans[m] = i if l <= m-1: heappush(que, (-cost(l, m-1), l, m-1)) if m+1 <= r: heappush(que, (-cost(m+1, r), m+1, r)) print(*ans)