#include<bits/stdc++.h>

using namespace std;

int t,n,k,c;

int main(){
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>n>>k;
        cout<<k/2+n-k<<endl;
        for(int i=k-k/2;i<k;i++) cout<<i<<" ";
        for(int i=k+1;i<=n;i++)  cout<<i<<" ";
        cout<<endl;
    }

}
