#include <bits/stdc++.h>
#define int long long
using namespace std;

int ans[100005];

signed main() {
	int t;
	cin >> t;
	int cnt = 0;
	while(t--) {
		int n, k;
		cin >> n >> k;
		for(int i = k - 1; i >= 1; --i) {
			if(k % 2 == 1 && i < (k + 1) / 2) break;
			else if(k % 2 == 0 && i < k / 2) break;
			ans[++cnt] = i;
		}
		for(int i = k + 1; i <= n; ++i) {
			ans[++cnt] = i;
		}
		cout << cnt << endl;
		for(int i = 1; i <= cnt; ++i) {
			cout << ans[i] <<" ";
		}
		cout << endl;
		cnt = 0;
	}
	return 0;
}