#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9;
const int M = 1e3 + 9;
const int INFINT = 1e9 + 9;
const long long INFLL = 1e18 + 9;
const long long MOD = 998244353ll;
void solve() {
  int n, d;
  cin >> n >> d;
  vector<int> a(5000);
  int q = n;
  int cnt = 1;
  int ind = 0;
  while (q > 0) {
    a[ind++] = min(cnt, q);
    q -= cnt;
    cnt *= 2;
  }
  int res = 0;
  for (int i = 0; i < (int)(int)(a.size()); ++i) {
    res += a[i] * i;
  }
  if (res > d) {
    cout << "NO\n";
    return;
  }
  for (int i = res; i < d; ++i) {
    int ind_up = -1;
    for (int j = 0; a[j] > 0; ++j) {
      if (a[j] > 1) {
        ind_up = j;
      }
    }
    if (ind_up == -1) {
      cout << "NO\n";
      return;
    }
    --a[ind_up];
    ++a[ind_up + 1];
  }
  vector<int> ans(n - 1);
  int pr_sum = 0;
  int ans_ind = 0;
  for (int i = 1; a[i] > 0; ++i) {
    int cnt_sum = 0;
    for (int j = 0; j < a[i]; ++j) {
      ans[ans_ind++] = pr_sum + 1 + cnt_sum / 2;
      ++cnt_sum;
    }
    pr_sum += a[i - 1];
  }
  cout << "YES\n";
  for (int i = 0; i < (int)(int)(ans.size()); ++i) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(time(nullptr));
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
