#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAX = 6000;
long long arr[MAX];
long long rpta[30];
long long ini[MAX];
int main() {
  int t;
  cin >> t;
  long long n, d;
  while (t--) {
    memset(arr, 0, sizeof(arr));
    cin >> n >> d;
    long long ind = 0;
    while (n) {
      arr[ind] = min(n, 1LL << ind);
      n -= arr[ind];
      ind++;
    }
    long long minimo = 0;
    for (long long i = (long long)(0); i < (long long)(ind); i++)
      minimo += i * arr[i];
    if (d < minimo)
      cout << "NO" << endl;
    else {
      long long sobra = d - minimo;
      long long act = ind - 1;
      while (sobra) {
        while (act && arr[act] == 1) act--;
        if (act == 0) break;
        arr[act]--;
        arr[++act]++;
        sobra--;
      }
      if (sobra)
        cout << "NO" << endl;
      else {
        cout << "YES" << endl;
        ini[0] = 1;
        long long sig = 2;
        long long ind = 1;
        bool imp = false;
        bool primera;
        while (arr[ind]) {
          primera = true;
          for (long long i = (long long)(0); i < (long long)(arr[ind]); i++) {
            if (imp)
              cout << " ";
            else
              imp = true;
            if (primera) ini[ind] = sig, primera = false;
            sig++;
            long long padre = ini[ind - 1] + (i / 2);
            cout << padre;
          }
          ind++;
        }
        cout << endl;
      }
    }
  }
}
