#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, k, v[1010];

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    cin >> t;

    while (t--) {
        cin >> n >> k;
        int dim = 0;
        for (int i = k + 1; i <= n; i++)
            v[dim++] = i;
        for (int i = k / 2 + k % 2; i < k; i++)
            v[dim++] = i;
        cout << dim << "\n";
        for (int i = 0; i < dim; i++)
            cout << v[i] << " ";
        cout << "\n";
    }
    return 0;
}
