#include <bits/stdc++.h>
using namespace std;
int n, Q, a[102];
bool f[102][102 * (102 + 1) >> 1];
struct tra {
  int cm, k, x, y;
} g[102][102 * (102 + 1) >> 1];
void Dich(int L, int R, int v, int l, int r) {
  if (L == R) {
    a[L] = l;
    return;
  }
  tra p = g[R - L + 1][v];
  int i, k = p.k, mid, ol = L, od = R;
  if (p.cm) {
    k -= 1;
    while (k--) a[R--] = r--;
    Dich(L, R, p.y, l, r);
  } else {
    if (k & 1) {
      mid = R - ((k + 1) >> 1) + 1;
      a[mid] = l++;
      for (i = mid + 1; i <= R; i++) a[i] = r--, a[2 * mid - i] = r--;
      ++r;
      Dich(L, R - k + 1, p.y, l, r);
      goto Ou;
    }
    for (i = R - k + 2; i <= R; i += 2) a[i] = l++;
    i--;
    if (i > R) i -= 2;
    for (; i > R - k + 2; i -= 2) a[i] = r--;
    Dich(L, R - k + 1, p.y, l, r);
  }
Ou:
  reverse(a + ol, a + od + 1);
}
int main() {
  f[1][1] = 1;
  int i, j, k, v, x, y, n;
  for (i = 1; i < 102; i++)
    for (j = 1; j < (102 * (102 + 1) >> 1); j++)
      if (v = f[i][j]) {
        for (k = 2; i + k < 102; k++)
          f[x = (i + k - 1)][y = (j + k * (k + 1) / 2 - 1)] = 1,
                                                        g[x][y] =
                                                            (tra){1, k, i, j};
        for (k = 4; i + k < 102; k++)
          f[x = (i + k - 1)][y = (j + k)] = 1, g[x][y] = (tra){0, k, i, j};
      }
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d%d", &n, &k);
    if (!f[n][k])
      printf("NO\n");
    else {
      printf("YES\n");
      Dich(1, n, k, 1, n);
      for (i = 1; i <= n; i++) printf("%d ", a[i]);
      printf("\n");
    }
  }
  return 0;
}
