/**
 * Author: lukasdeimos
*/

#include<bits/stdc++.h>

#define endl '\n'

#define ff first
#define ss second

using ll = long long;
using namespace std;

void solve() {
	int n,k;
	cin >> n >> k;

	cout << (n-k+k/2) << endl;
	for(int i = k+1; i <= n; i++) cout << i << " ";
	for(int i = (k+1)/2; i < k; i++) cout << i << " ";
	cout << endl;

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	ll tt;
	tt = 1;
	 cin >> tt;
	for(auto test_case = 1; test_case <= tt; test_case++) {
	//	cout << "Case " << test_case << ": ";
		solve();
	}
	

	return 0;
}
