#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 int main(){ int _t; cin>>_t; rep(_,_t){ int N,M; cin>>N>>M; M--; vector<int> ans(N,-1); ans[M] = 0; set<pair<int,int>> s; set<int> pos; pos.insert(M); if(M!=0)s.emplace(-(M),0); if(M!=N-1)s.emplace(-(N-1-(M)),N-1); for(int i=1;i<N;i++){ auto x = *s.begin(); s.erase(s.begin()); ans[x.second] = i; //cout<<x.first<<' '<<x.second<<endl; { auto it = pos.lower_bound(x.second); if(it==pos.end()){ } else{ int d = (*it) - x.second; d /= 2; if(d!=0){ s.emplace(-d,x.second+d); } } } { auto it = pos.lower_bound(x.second); if(it==pos.begin()){ } else{ it--; int d = x.second - (*it); d /= 2; if(d!=0){ s.emplace(-d,(*it)+d); } } } pos.insert(x.second); } rep(i,N){ if(i!=0)cout<<' '; cout<<ans[i]+1; } cout<<endl; } return 0; }