for _ in range(int(input())):
a, b = map(int, input().split())
l = []
for i in range(a, 0, -1):
if b - i not in l and i != b and sum(l) + i != b:
l.append(i)
print(len(l))
print(*l)
#include<bits/stdc++.h>
#define ll long long
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define test int t ; cin >> t ; while(t--)
#define rep(i,a,b) for (int i = a; i < b; i++)
const ll mod = 1e9 + 7;
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_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
cin >> t ;
while (t--) {
solve() ;
};
return 0 ;
}
1624C - Division by Two and Permutation | 1288A - Deadline |
1617A - Forbidden Subsequence | 914A - Perfect Squares |
873D - Merge Sort | 1251A - Broken Keyboard |
463B - Caisa and Pylons | 584A - Olesya and Rodion |
799A - Carrot Cakes | 1569B - Chess Tournament |
1047B - Cover Points | 1381B - Unmerge |
1256A - Payment Without Change | 908B - New Year and Buggy Bot |
979A - Pizza Pizza Pizza | 731A - Night at the Museum |
742A - Arpa’s hard exam and Mehrdad’s naive cheat | 1492A - Three swimmers |
1360E - Polygon | 1517D - Explorer Space |
1230B - Ania and Minimizing | 1201A - Important Exam |
676A - Nicholas and Permutation | 431A - Black Square |
474B - Worms | 987B - High School Become Human |
1223A - CME | 1658B - Marin and Anti-coprime Permutation |
14B - Young Photographer | 143A - Help Vasilisa the Wise 2 |