#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j,  n, m, l, t, k, key, res, need; char cch;
    cin>>t;
    while(t--){
            cin>>n>>k;
            l = (k+1)/2;
            cout<<n-l<<endl;
            for(i=l; i<=n; i++)
                if(i!=k) cout<<i<<' ';
            cout<<endl;
    }
    return 0;
}
