/****************************************** * AUTHOR: BHUVNESH JAIN * * INSTITUITION: BITS PILANI, PILANI * ******************************************/ #include using namespace std; typedef long long LL; typedef long double LD; typedef pair pii; typedef pair pll; const int MAX = 1e5 + 5; LL dp[MAX]; int q; vector lena_sort(vector nums) { if (nums.size() <= 1) { return nums; } int pivot = nums[0]; vector less; vector more; for (int i = 1; i < nums.size(); ++i) { // Comparison q += 1; if (nums[i] < pivot) { less.push_back(nums[i]); } else { more.push_back(nums[i]); } } vector sorted_less = lena_sort(less); vector sorted_more = lena_sort(more); vector ans; for(auto it : sorted_less) ans.push_back(it); ans.push_back(pivot); for(auto it : sorted_more) ans.push_back(it); // ans = sorted_less + pivot + sorted_more; return ans; } int main() { #ifndef ONLINE_JUDGE //freopen("inp.txt", "r", stdin); #endif dp[1] = 0; dp[2] = 1; for(int i = 3; i < MAX; ++i) { dp[i] = i-1 + dp[i/2] + dp[(i-1)/2]; } int t; LL n, c; scanf("%d", &t); while(t--) { scanf("%lld %lld", &n, &c); if (n == 1) { if (c == 0) { printf("1\n"); } else { printf("-1\n"); } continue; } LL w = n * (n-1) / 2; if (w < c) { printf("-1\n"); continue; } else if (c < dp[n]) { printf("-1\n"); continue; } assert(dp[n] <= c && c <= w); vector a(n); for(int i = 1; i <= n; ++i) { a[i-1] = i; } do { q = 0; vector ans = lena_sort(a); if (q == c) { for(auto it : a) printf("%d ", it); break; } }while(next_permutation(a.begin(), a.end())); printf("\n"); } return 0; }