#include <iostream>
using namespace std;

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