#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

using S = array<pair<int,int>, 3>;

pair<int,int> comp(pair<int,int> lhs, pair<int,int> rhs){
    if(lhs.first == rhs.first) {
        return lhs.second < rhs.second ? lhs : rhs;
    }
    return lhs.first > rhs.first ? lhs : rhs;
}

S op(S lhs, S rhs){
    if(lhs[0].first == -1) return rhs;
    if(rhs[0].first == -1) return lhs;
    S tmp;
    tmp[0] = comp(lhs[0], rhs[0]);
    tmp[1] = lhs[1];
    tmp[2] = rhs[2];
    int d = abs(rhs[1].second - lhs[2].second) / 2;
    tmp[0] = comp(tmp[0], make_pair(d, lhs[2].second + d));
    return tmp;
}
S e(){
    pair<int,int> tmp = {-1, -1};
    return S({tmp, tmp, tmp});
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        int n, m;
        cin >> n >> m;
        m--;
        vector<int> ans(n);
        ans[m] = 1;
        atcoder::segtree<S, op, e> seg(n);
        pair<int,int> tmp;
        tmp = make_pair(0, m);
        seg.set(m, S({tmp, tmp, tmp}));
        for(int i = 2; i <= n; i++){
            auto pa = seg.all_prod();
            if(seg.get(0)[0].first != 0){
                int d = pa[1].second;
                pa[0] = comp(pa[0], make_pair(d, 0));
            }
            if(seg.get(n - 1)[0].first != 0){
                int d = (n - 1 - pa[2].second);
                pa[0] = comp(pa[0], make_pair(d, n - 1));
            }
            int c = pa[0].second;
            ans[c] = i;
            tmp = make_pair(0, c);
            seg.set(c, S({tmp, tmp, tmp}));
        }
        cout << ans << '\n';
    }
}