#include <bits/stdc++.h>
using namespace std;
const long long N = 5e3 + 10;
long long n, d, nn, dd;
long long num[N], num1[N], tr[N];
bool check(long long cnt, long long p) {
  long long td = cnt, ti = p;
  long long tn1 = n, td1 = d;
  long long tn2 = n, td2 = d;
  long long x = 0, y = 0;
  long long last = p;
  while (tn1) {
    x += td * min(ti, tn1);
    tn1 -= min(ti, tn1);
    td++, ti *= 2;
  }
  y = x * cnt + x * (x - 1) / 2;
  return x <= d && d <= y;
}
bool work(long long x) {
  long long l = 1, r = num[x - 1] * 2;
  bool flag = 1;
  for (long long i = l; i <= r; i++) {
    if (check(x, i)) {
      num[x] = i;
      n -= i;
      d -= x * i;
      flag = 0;
      break;
    }
  }
  return flag;
}
struct node {
  long long x, t;
  bool operator<(const node &b) const { return t < b.t; }
  node() { x = 0, t = 0; }
  node(long long a, long long b) { x = a, t = b; }
} a[N];
bool cmp(node a, node b) { return a.x < b.x; }
priority_queue<node> que;
bool ok(long long x) {
  long long sum1 = 0, sum2 = 0;
  for (long long i = 0; i <= x; i++) {
    sum1 += num[i], sum2 += i * num[i];
    if (i > 0 && (num[i] < 1 || num[i] > num[i - 1] * 2)) return 0;
  }
  return sum1 == nn && sum2 == dd;
}
long long c[N][2], mapv[N];
long long lowbit(long long x) { return x & (-x); }
void add(long long x, long long val) {
  while (x <= n) c[x][0]++, c[x][1] += val, x += lowbit(x);
}
long long ask(long long x, long long k) {
  long long res = 0;
  while (x) res += c[x][k], x -= lowbit(x);
  return res;
}
void solve() {
  cin >> n >> d;
  nn = n, dd = d;
  long long cnt = 0;
  num[0] = 1;
  n--;
  while (n) {
    bool flag = work(++cnt);
    if (flag) break;
  }
  if (!ok(cnt))
    cout << "NO" << '\n';
  else {
    cout << "YES" << '\n';
    long long now = 0;
    for (long long i = 1; i <= cnt; i++) num[i] += num[i - 1];
    for (long long i = 1; i <= cnt; i++) {
      long long l = 1, r = num[i - 1];
      if (i - 2 >= 0) l = max(l, num[i - 2] + 1);
      long long x = num[i - 1] + 1, y = num[i];
      for (long long j = l; j <= r; j++) {
        tr[x] = j;
        x++;
        if (x > y) break;
        tr[x] = j;
        x++;
        if (x > y) break;
      }
    }
    for (long long i = 2; i <= nn; i++) cout << tr[i] << " ";
    cout << '\n';
  }
}
long long Real(long long x) { ; }
struct EDGE {
  long long to, next;
  long long dis;
} edge[N];
struct n1ode {
  long long pos;
  long long dis;
  friend bool operator<(node a, node b) { ; }
};
long long tot;
long long head[N];
long long dis[N];
bool vis[N];
void Init(long long n) {
  for (long long i = 1; i <= n; ++i) dis[i] = 0;
}
void add(long long from, long long to, long long cost) {
  ++tot;
  edge[tot].to = to;
  edge[tot].dis = cost;
  edge[tot].next = head[from];
  head[from] = tot;
}
priority_queue<node> q;
void Dijkstra(long long s) {
  dis[s] = 0;
  q.push({s, 0});
  while (!q.empty()) {
    node tmp = q.top();
    q.pop();
    long long x = 1;
    if (vis[x]) continue;
    vis[x] = 1;
    for (long long i = head[x]; i; i = edge[i].next) {
      long long y = edge[i].to;
      if (dis[y] > dis[x] + edge[i].dis) {
        dis[y] = dis[x] + edge[i].dis;
        if (!vis[y]) {
          q.push({y, dis[y]});
        }
      }
    }
  }
}
signed main() {
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 5e3 + 10;
long long n, d, nn, dd;
long long num[N], num1[N], tr[N];
bool check(long long cnt, long long p) {
  long long td = cnt, ti = p;
  long long tn1 = n, td1 = d;
  long long tn2 = n, td2 = d;
  long long x = 0, y = 0;
  long long last = p;
  while (tn1) {
    x += td * min(ti, tn1);
    tn1 -= min(ti, tn1);
    td++, ti *= 2;
  }
  y = x * cnt + x * (x - 1) / 2;
  return x <= d && d <= y;
}
bool work(long long x) {
  long long l = 1, r = num[x - 1] * 2;
  bool flag = 1;
  for (long long i = l; i <= r; i++) {
    if (check(x, i)) {
      num[x] = i;
      n -= i;
      d -= x * i;
      flag = 0;
      break;
    }
  }
  return flag;
}
struct node {
  long long x, t;
  bool operator<(const node &b) const { return t < b.t; }
  node() { x = 0, t = 0; }
  node(long long a, long long b) { x = a, t = b; }
} a[N];
bool cmp(node a, node b) { return a.x < b.x; }
priority_queue<node> que;
bool ok(long long x) {
  long long sum1 = 0, sum2 = 0;
  for (long long i = 0; i <= x; i++) {
    sum1 += num[i], sum2 += i * num[i];
    if (i > 0 && (num[i] < 1 || num[i] > num[i - 1] * 2)) return 0;
  }
  return sum1 == nn && sum2 == dd;
}
long long c[N][2], mapv[N];
long long lowbit(long long x) { return x & (-x); }
void add(long long x, long long val) {
  while (x <= n) c[x][0]++, c[x][1] += val, x += lowbit(x);
}
long long ask(long long x, long long k) {
  long long res = 0;
  while (x) res += c[x][k], x -= lowbit(x);
  return res;
}
void solve() {
  cin >> n >> d;
  nn = n, dd = d;
  long long cnt = 0;
  num[0] = 1;
  n--;
  while (n) {
    bool flag = work(++cnt);
    if (flag) break;
  }
  if (!ok(cnt))
    cout << "NO" << '\n';
  else {
    cout << "YES" << '\n';
    long long now = 0;
    for (long long i = 1; i <= cnt; i++) num[i] += num[i - 1];
    for (long long i = 1; i <= cnt; i++) {
      long long l = 1, r = num[i - 1];
      if (i - 2 >= 0) l = max(l, num[i - 2] + 1);
      long long x = num[i - 1] + 1, y = num[i];
      for (long long j = l; j <= r; j++) {
        tr[x] = j;
        x++;
        if (x > y) break;
        tr[x] = j;
        x++;
        if (x > y) break;
      }
    }
    for (long long i = 2; i <= nn; i++) cout << tr[i] << " ";
    cout << '\n';
  }
}
long long Real(long long x) { ; }
struct EDGE {
  long long to, next;
  long long dis;
} edge[N];
struct n1ode {
  long long pos;
  long long dis;
  friend bool operator<(node a, node b) { ; }
};
long long tot;
long long head[N];
long long dis[N];
bool vis[N];
void Init(long long n) {
  for (long long i = 1; i <= n; ++i) dis[i] = 0;
}
void add(long long from, long long to, long long cost) {
  ++tot;
  edge[tot].to = to;
  edge[tot].dis = cost;
  edge[tot].next = head[from];
  head[from] = tot;
}
priority_queue<node> q;
void Dijkstra(long long s) {
  dis[s] = 0;
  q.push({s, 0});
  while (!q.empty()) {
    node tmp = q.top();
    q.pop();
    long long x = 1;
    if (vis[x]) continue;
    vis[x] = 1;
    for (long long i = head[x]; i; i = edge[i].next) {
      long long y = edge[i].to;
      if (dis[y] > dis[x] + edge[i].dis) {
        dis[y] = dis[x] + edge[i].dis;
        if (!vis[y]) {
          q.push({y, dis[y]});
        }
      }
    }
  }
}
signed main() {
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}

```