#include<iostream>

using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k,a;
		cin>>n>>k;
		int temp;
		if(k%2==0)
		temp=k/2;
		else
		temp=k/2;
		a=(n-k)+temp;
		int b[a];
		for(int i=0;i<a;i++)
		{
			if(n>k)
			{
				b[i]=n;
				n--;
			}
			else if(k>=n)
			{
				b[i]=n-1;
				n--;
			}
		}
		cout<<a<<endl;
		for(int i=0;i<a;i++)
		cout<<b[i]<<" ";
		cout<<endl; 	
	}
 return 0;
}