import heapq T = int(input()) for _ in range(T): N, M = map(int, input().split()) ans = [-1] * N ans[M - 1] = 1 hq = [] # (distance,pos,left,right) if M - 1 != 0: heapq.heappush(hq, (-(M - 1), 0, -1, M - 1)) if M != N: heapq.heappush(hq, (-(N - M), N - 1, M - 1, -1)) count = 1 while len(hq) != 0: count += 1 dis, pos, left, right = heapq.heappop(hq) ans[pos] = count if left != -1 and pos - left != 1: next = (pos + left) // 2 heapq.heappush(hq, (-(next - left), next, left, pos)) if right != -1 and right - pos != 1: next = (pos + right) // 2 heapq.heappush(hq, (-(next - pos), next, pos, right)) print(*ans)