#include using namespace std; #define FOR(i,a,b) for (int i = (a); i <= (b); i++) #define FORD(i,a,b) for (int i = (a); i >= (b); i--) #define REP(i,a) FOR(i,0,(int)(a)-1) #define reset(a,b) memset(a,b,sizeof(a)) #define BUG(x) cout << #x << " = " << x << endl #define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;} #define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;} #define mod 1000000007 #define pi acos(-1) #define eps 0.00000001 #define pb push_back #define sqr(x) (x) * (x) #define _1 first #define _2 second long long mmin[100005], mmax[100005], len, c; void solve(long long st, long long len, long long t) { // BUG(len); if (len < 3) { REP (i, len) cout << st + i << ' '; return ; } t -= len - 1; REP (i, len) if (t >= mmin[i] + mmin[len - 1 - i] && t <= mmax[i] + mmax[len - 1 - i]) { // BUG(i); cout << st + i << ' '; long long chs = max(mmin[i], t - mmax[len - 1 - i]); solve(st, i, chs); solve(st + i + 1, len - 1 - i, t - chs); return ; } } int main() { ios::sync_with_stdio(false); mmin[2] = mmax[2] = 1; FOR (i, 3, 100000) { mmax[i] = i; mmax[i] *= i - 1; mmax[i] /= 2; int j = i / 2; int k = (i - 1) / 2; mmin[i] = i - 1 + mmin[j] + mmin[k]; } int q; cin >> q; while (q--) { cin >> len >> c; if (c < mmin[len] || c > mmax[len]) cout << -1; else solve(1, len, c); cout << endl; } }