
// Problem: A. Anti-knapsack
// Contest: Codeforces - Codeforces Round #705 (Div. 2)
// URL: https://codeforces.com/contest/1493/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Author: ThinkTwice (CodeForces, AtCoder)/ roastedcoderr(CodeChef)

#include<bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int MOD = 1e9 + 7;
//const int ULTRA = 1e14;
const int PROMAX = 1e6 + 5;
const int PRO = 1e7 + 1;

#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define lla(x) x.rbegin(), x.rend()
#define pb push_back
#define ThinkTwice ios_base::sync_with_stdio(false); cin.tie(NULL);
int    dx[] = {-1,  0,  1,  0, -1, -1,  1,  1};
int    dy[] = { 0,  1,  0, -1, -1,  1,  1, -1};
char  dir[] = {'U','R','D','L'};
inline int powmod(int a, int b, int mod) {int res=1; while(b>0) {if(b&1) res=(res*a)%mod; a=(a*a)%mod; b>>=1; } return res;}
inline int power(int a, int b) {int res=1; while(b>0) {if(b&1) res*=a; a*=a; b>>=1;} return res; }
//__________________________________________________________________


void solve() {
    int n, k; cin>>n>>k;
    vector <int> a;
    for(int i = (k+1)/2; i<=n; i++) if(i != k) a.pb(i);
    cout<<a.size()<<endl;
    for(auto x: a) cout<<x<<" ";
    cout<<endl;
    
}

signed main() {
	ThinkTwice
	int t;
	
	// t = 1;
	cin>>t;

	for(int i = 1; i<=t; i++) {
		// cout<<"Case #"<<i<<": ";
		solve();
	}
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/
