#include using namespace std; typedef long long int ll; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int q; cin >> q; while (q--) { int n, k; cin >> n >> k; if (n == 2 or k <= 1 or k == n) { cout << "No" << "\n"; continue; } cout << "Yes" << "\n"; int tmp1 = 3 * n - 3; int tmp2 = 4; for (int i = 0; i < 3; i++) { cout << i + 1; int uo = k - 2; for (int j = 0; j < n - 2; j++) { if (uo > 0) { cout << " " << tmp2; tmp2 += 1; uo -= 1; } else { cout << " " << tmp1; tmp1 -= 1; } } cout << " " << (i == 2 ? 1 : i + 2) << "\n"; } } }