#include #define ff first #define ss second #define pb push_back #define MOD (1000000007LL) #define LEFT(n) (2*(n)) #define RIGHT(n) (2*(n)+1) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair ii; typedef pair iii; ll pwr(ll base, ll p, ll mod = MOD){ ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans; } ll gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a%b); } typedef vector VD; typedef vector VVD; typedef vector VI; int q,le,c,z; int mi[1000006]; int ma[1000006]; int num[1000006]; VI ans; int fun(int comp, int len, int pos) { // return 1; // printf("%d %d %d %d %d\n",pos,len,comp,mi[pos],ma[len-pos]); if(mi[pos] + ma[len-pos] >= comp && mi[pos] + mi[len-pos] <= comp ) return pos; else if(mi[pos] + ma[len-pos] <= comp) return fun(comp,len,pos/2); else return fun(comp,len,pos+pos/2); } void lena_sort_(int st, int en, int comp) { if(en < st) return; if(st == en) { ans.push_back(st); return ; } if(en == st+1) { ans.push_back(st); ans.push_back(st+1); return; } int len = en-st+1; comp -= len-1; int a = fun(comp,len-1,(len-1)/2); // printf("%d %d %d %d\n",st,en,comp,a); ans.push_back(st+a); // if(z == 1) // return; // z = 1; lena_sort_(st,st+a-1,mi[a]); lena_sort_(st+a+1,en,comp-mi[a]); } int main() { scanf("%d",&q); mi[1] = 0; ma[1] = 0; num[1] = 1; for(int i=2;i<1000001;i++) { num[i] = i; ma[i] = ma[i-1] + i-1; mi[i] = mi[(i-1)/2] + mi[(i)/2] + i-1; } while(q--) { ans.clear(); scanf("%d %d",&le,&c); if( c < mi[le] || c > ma[le]) { printf("-1\n"); continue; } // printf("%d %d\n",le,c); lena_sort_(1,le,c); for(int i=0;i