import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int t = sc.nextInt();
        String result = IntStream.range(0, t).mapToObj(i -> {
            int n = sc.nextInt();
            int m = sc.nextInt();
            PriorityQueue<Space> queue = new PriorityQueue<>();
            int[] ans = new int[n];
            ans[m - 1] = 1;
            if (m > 1) {
                queue.add(new Space(1, m - 1));
            }
            if (m < n) {
                queue.add(new Space(n, n - m));
            }
            TreeSet<Integer> exists = new TreeSet<>();
            exists.add(m);
            int current = 2;
            while (queue.size() > 0) {
                Space x = queue.poll();
                ans[x.idx - 1] = current++;
                if (x.idx > 1) {
                    int left = exists.lower(x.idx);
                    if (left + 1 < x.idx) {
                        queue.add(new Space((left + x.idx) / 2, (left + x.idx) / 2 - left));
                    }
                }
                if (x.idx < n) {
                    int right = exists.higher(x.idx);
                    if (right - 1 > x.idx) {
                        queue.add(new Space((right + x.idx) / 2, (right + x.idx) / 2 - x.idx));
                    }
                }
                exists.add(x.idx);
            }
            return Arrays.stream(ans).mapToObj(String::valueOf).collect(Collectors.joining(" "));
        }).collect(Collectors.joining("\n"));
        System.out.println(result);
    }
    
    static class Space implements Comparable<Space> {
        int idx;
        int value;
        
        public Space(int idx, int value) {
            this.idx = idx;
            this.value = value;
        }
        
        public int compareTo(Space another) {
            if (value == another.value) {
                return idx - another.idx;
            } else {
                return another.value - value;
            }
        }
        
        public String toString() {
            return idx + ":" + value;
        }
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}