#include using namespace std; #pragma comment(linker, "/STACK: 2000000") #define ll long long #define sd(t) scanf("%d",&(t)) #define pd(t) printf("%d\n",(t)) #define pii pair #define pb push_back #define F first #define S second #define mp make_pair const int mod = 1e9+7; inline int add(int i, int j){ i+=j; if(i>=mod) i-=mod; return i;} inline int sub(int i, int j){ i-=j; if(i<0) i+=mod; return i;} inline int mul(int i, int j){return (i*1ll*j)%mod;} inline int powr(int a, int b){ int x = 1; while(b){ if(b&1) x = mul(x,a); a = mul(a,a); b>>=1; } return x; } const int N = 1e6+10; int dp[N]; ll C2(int l){return (l*1ll*(l-1))/2;} #define eb emplace_back #define print(s) cout<<#s<<" : ";for(auto i:(s))cout< perm(int i, int j, int c, int n){ if(n==0){return {};} if(n == 1) return {i}; int _c = c-n+1, cleft; int lo = 1, hi = (n+1)/2; while(lo < hi){ int mid = (lo+hi)>>1; if(dp[mid-1] + dp[n-mid] <= _c) hi = mid; else lo = mid+1; } ll a1 = dp[lo-1], b1 = C2(lo-1), a2 = dp[n-lo], b2 = C2(n-lo); ll x = max(a1,_c-b2); vector ret; ret.eb(i+lo-1); vector ret1 = perm(i,i+lo-2,x,lo-1); vector ret2 = perm(i+lo,j,_c-x,n-lo); for(int val:ret1) ret.eb(val); for(int val:ret2) ret.eb(val); return ret; } vector ans,ans2; int main(){ dp[1] = 0; for(int i = 2;i>1, i2 = i-1-i1; dp[i] = dp[i1]+dp[i2]+i-1; } int q,l,c; cin.tie(0); cin>>q; while(q--){ ans.clear(); cin>>l>>c; if(c < dp[l] || c > C2(l)){ cout<<-1< 0 && l-1 + dp[l-1] <= c){ ans.eb(x++); c -= (l-1); l--; } ans2 = perm((int)ans.size()+1,L,c,l); for(int v:ans2) ans.eb(v); for(int v:ans) cout<