#include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 0, n = 0, d = 0, c = 0, x = 0, flag = 0, f = 0;
  cin >> t;
  while (t--) {
    memset(a, 0, sizeof(a));
    cin >> n >> d;
    a[0] = 1;
    c = 1;
    for (int i = 1; i <= 10; ++i) {
      x = min(d / i, n - c);
      x = min(x, 1 << i);
      a[i] = x;
      c += x;
      d -= (x * i);
    }
    if (c < n) {
      cout << "NO" << endl;
      continue;
    }
    flag = 0;
    while (d--) {
      f = 0;
      for (int i = 2; i <= 100; ++i) {
        if (a[i - 1] > 1 && 2 * a[i - 1] >= a[i] + 3) {
          a[i - 1]--;
          a[i]++;
          f = 1;
          break;
        }
      }
      if (!f) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
    vector<int> v;
    v.push_back(1);
    c = 1;
    for (int i = 1; i <= 100; ++i) {
      vector<int> g;
      for (int j = 1; j <= a[i]; ++j) {
        ++c;
        g.push_back(c);
        cout << v[(j - 1) / 2] << " ";
      }
      v = g;
    }
    cout << endl;
  }
}
