#include<bits/stdc++.h>
#define ll long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
 
int main()
{
   fio;
   ll t=0;
   cin>>t;
   for(ll z=0; z<t; z++){  
      ll n, k;
      cin>>n>>k;
      vector<ll> ans;
      ll countans = 0;
      for(int i = k-1; i > (k-1)/2; i--){
         ans.push_back(i);
         countans++;
      }
      for(int i = k + 1; i <= n; i++){
         ans.push_back(i);
         countans++;
      }
      cout<<countans<<"\n";
      for(auto i: ans){
         cout<<i<<" ";
      }
      cout<<"\n";
   }
   return 0;
}