#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  register T sum = 0;
  register char cc = getchar();
  int sym = 1;
  while (cc != '-' && (cc > '9' || cc < '0')) cc = getchar();
  if (cc == '-') sym = -1, cc = getchar();
  sum = sum * 10 + cc - '0';
  cc = getchar();
  while (cc >= '0' && cc <= '9') sum = sum * 10 + cc - '0', cc = getchar();
  return sym * sum;
}
template <typename T>
inline T read(T& a) {
  a = read<T>();
  return a;
}
template <typename T, typename... Others>
inline void read(T& a, Others&... b) {
  a = read(a);
  read(b...);
}
int T, n, d, sum, mx, fa[5010], cnt[5010], dep[5010], tree[5010][5010];
void ins(int k, int f) {
  dep[k] = dep[f] + 1;
  tree[dep[k]][++cnt[dep[k]]] = k;
  sum += dep[k];
  mx = max(mx, dep[k]);
}
int main() {
  read(T);
  for (int cas = 1; cas <= T; cas++) {
    read(n, d);
    memset(fa + 1, 0, sizeof(int) * n);
    memset(cnt + 1, 0, sizeof(int) * n);
    sum = mx = 0;
    tree[0][++cnt[0]] = 1;
    for (int i = 1; i <= n; i++) {
      int l = i << 1, r = i << 1 | 1;
      if (l <= n) ins(l, i);
      if (r <= n) ins(r, i);
    }
    if (sum > d || d > n * (n - 1) / 2) {
      puts("NO");
      continue;
    }
    while (sum < d) {
      for (int i = mx; i >= 0; i--) {
        if (cnt[i] >= 2 && cnt[i + 1] < (cnt[i] - 1) << 1) {
          tree[i + 1][++cnt[i + 1]] = tree[i][cnt[i]];
          cnt[i] -= 1;
          sum += 1;
          mx = max(mx, i + 1);
          break;
        }
      }
    }
    for (int j = 0; j < mx; j++)
      for (int i = 1; i <= cnt[j]; i++) {
        int l = 2 * (i - 1) + 1, r = 2 * (i - 1) + 2;
        if (l <= cnt[j + 1]) fa[tree[j + 1][l]] = tree[j][i];
        if (r <= cnt[j + 1]) fa[tree[j + 1][r]] = tree[j][i];
      }
    puts("YES");
    for (int i = 2; i <= n; i++) printf("%d ", fa[i]);
    putchar('\n');
  }
  return 0;
}

### Prompt

Please provide a Cpp coded solution 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;
template <typename T>
inline T read() {
  register T sum = 0;
  register char cc = getchar();
  int sym = 1;
  while (cc != '-' && (cc > '9' || cc < '0')) cc = getchar();
  if (cc == '-') sym = -1, cc = getchar();
  sum = sum * 10 + cc - '0';
  cc = getchar();
  while (cc >= '0' && cc <= '9') sum = sum * 10 + cc - '0', cc = getchar();
  return sym * sum;
}
template <typename T>
inline T read(T& a) {
  a = read<T>();
  return a;
}
template <typename T, typename... Others>
inline void read(T& a, Others&... b) {
  a = read(a);
  read(b...);
}
int T, n, d, sum, mx, fa[5010], cnt[5010], dep[5010], tree[5010][5010];
void ins(int k, int f) {
  dep[k] = dep[f] + 1;
  tree[dep[k]][++cnt[dep[k]]] = k;
  sum += dep[k];
  mx = max(mx, dep[k]);
}
int main() {
  read(T);
  for (int cas = 1; cas <= T; cas++) {
    read(n, d);
    memset(fa + 1, 0, sizeof(int) * n);
    memset(cnt + 1, 0, sizeof(int) * n);
    sum = mx = 0;
    tree[0][++cnt[0]] = 1;
    for (int i = 1; i <= n; i++) {
      int l = i << 1, r = i << 1 | 1;
      if (l <= n) ins(l, i);
      if (r <= n) ins(r, i);
    }
    if (sum > d || d > n * (n - 1) / 2) {
      puts("NO");
      continue;
    }
    while (sum < d) {
      for (int i = mx; i >= 0; i--) {
        if (cnt[i] >= 2 && cnt[i + 1] < (cnt[i] - 1) << 1) {
          tree[i + 1][++cnt[i + 1]] = tree[i][cnt[i]];
          cnt[i] -= 1;
          sum += 1;
          mx = max(mx, i + 1);
          break;
        }
      }
    }
    for (int j = 0; j < mx; j++)
      for (int i = 1; i <= cnt[j]; i++) {
        int l = 2 * (i - 1) + 1, r = 2 * (i - 1) + 2;
        if (l <= cnt[j + 1]) fa[tree[j + 1][l]] = tree[j][i];
        if (r <= cnt[j + 1]) fa[tree[j + 1][r]] = tree[j][i];
      }
    puts("YES");
    for (int i = 2; i <= n; i++) printf("%d ", fa[i]);
    putchar('\n');
  }
  return 0;
}

```