You are given two integers n and d. You need to construct a rooted binary tree consisting of n vertices with a root at the vertex 1 and the sum of depths of all vertices equals to d.

A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. A parent of a vertex v is the last different from v vertex on the path from the root to the vertex v. The depth of the vertex v is the length of the path from the root to the vertex v. Children of vertex v are all vertices for which v is the parent. The binary tree is such a tree that no vertex has more than 2 children.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.

The only line of each test case contains two integers n and d (2 ≤ n, d ≤ 5000) — the number of vertices in the tree and the required sum of depths of all vertices.

It is guaranteed that the sum of n and the sum of d both does not exceed 5000 (∑ n ≤ 5000, ∑ d ≤ 5000).

Output

For each test case, print the answer.

If it is impossible to construct such a tree, print "NO" (without quotes) in the first line. Otherwise, print "{YES}" in the first line. Then print n-1 integers p_2, p_3, ..., p_n in the second line, where p_i is the parent of the vertex i. Note that the sequence of parents you print should describe some binary tree.

Example

Input


3
5 7
10 19
10 18


Output


YES
1 2 1 3 
YES
1 2 3 3 9 9 2 1 6 
NO

Note

Pictures corresponding to the first and the second test cases of the example:

<image>

<image>
#include <bits/stdc++.h>
using namespace std;
const long long INFL = 1LL << 60;
const int INF = 1 << 30;
long long MOD = 1000000007;
double EPS = 1e-11;
vector<long long> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<long long> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
void pres(double A) { printf("%.12lf\n", A); }
void BinarySay(long long x, long long y = 60) {
  for (int i = 0; i < (y); i++) cout << (x >> (y - 1 - i) & 1);
  cout << endl;
}
long long cnt_bit(long long x) { return __builtin_popcountll(x); }
long long pow_long(long long x, long long k) {
  long long res = 1;
  while (k > 0) {
    if (k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
long long pow_mod(long long x, long long k) {
  x %= MOD;
  long long res = 1;
  while (k > 0) {
    if (k % 2) {
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    k /= 2;
  }
  return res;
}
long long inverse(long long x) { return pow_mod(x, MOD - 2); };
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long x, long long y) {
  long long res = x / gcd(x, y);
  res *= y;
  return res;
};
const int MAXcomb = 2000010;
long long fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAXcomb; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}
const int MAXkai = 200010;
long long kai_memo[MAXkai];
long long kai(long long N) {
  if (kai_memo[N] != 0) return kai_memo[N];
  if (N <= 1) return 1;
  return kai_memo[N] = N * kai(N - 1) % MOD;
}
long long disit(long long second, long long base = 10) {
  long long res = 0;
  while (second) {
    res++;
    second /= base;
  }
  return res;
}
vector<pair<long long, long long>> MakePrimeList(long long x) {
  vector<pair<long long, long long>> res;
  for (long long k = 2; k * k <= x; k++) {
    if (x % k == 0) {
      long long cnt = 0;
      while (x % k == 0) {
        x /= k;
        cnt++;
      }
      res.push_back({k, cnt});
    }
  }
  if (x > 1) res.push_back({x, 1});
  return res;
}
void solve() {
  int n, d;
  cin >> n >> d;
  if (d > (n - 1) * n / 2) {
    cout << "NO" << endl;
    return;
  }
  int rest = n;
  int now = 0;
  int sum = 0;
  while (rest) {
    int dec = min((int)pow_long(2, now), rest);
    sum += now * dec;
    rest -= dec;
    now++;
  }
  if (sum > d) {
    cout << "NO" << endl;
    return;
  }
  cout << "YES" << endl;
  vector<int> depth(n), p(n), ch(n, 1);
  set<int> E[d + 1];
  sum = 0;
  for (int i = 0; i < n; i++) {
    p[i] = i - 1;
    depth[i] = i;
    E[i].insert(i);
    sum += i;
  }
  ch[n - 1] = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (sum == d) break;
    if (ch[i]) continue;
    for (int j = 0; j <= d; j++) {
      if (depth[i] <= j + 1) continue;
      if (sum - (depth[i] - j - 1) < d) continue;
      for (auto itr = E[j].begin(); itr != E[j].end(); itr++) {
        int v = *itr;
        if (ch[v] == 2) continue;
        E[depth[i]].erase(i);
        E[j + 1].insert(i);
        ch[p[i]]--;
        p[i] = v;
        ch[v]++;
        sum -= depth[i] - (j + 1);
        depth[i] = j + 1;
      }
    }
  }
  for (int i = 0; i < (n); i++) {
    if (i == 0) continue;
    cout << p[i] + 1;
    if (i == n - 1)
      cout << endl;
    else
      cout << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  for (int i = 0; i < (T); i++) solve();
}
