#include <iostream>
#include <vector>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int>a;
        for(int i=k+1;i<=n;++i){
            a.push_back(i);
        }
        for(int i=(k+1)/2;i<k;++i){
                a.push_back(i);
        }
        cout<<a.size()<<endl;
        for(int i=0;i<a.size();++i){
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}