#include <bits/stdc++.h>
#define pb push_back
#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector <ll> vll;
typedef pair<ll,ll> pll;
typedef vector <pair<ll,ll>> vpll;
typedef vector <vll> vvll;

const ll N=1e5+1;
ll t,n,k;

int main()
{
    speed;
    cin>>t;
    while(t--)
    {
        cin>>n>>k;
        vll ans;
        cout<<n-(k+1)/2<<"\n";
        for(int i=(k+1)/2;i<=n;i++)
            if(i!=k)
                cout<<i<<" ";
        cout<<"\n";
    }
    return 0;
}