#include <bits/stdc++.h>
#define int long long
#define float double
#define sz 100005
#define all(a) a.begin(), a.end()
#define mod 1000000007
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int>>
#define debug cout << "here" << endl;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define ff first
#define ss second
#define pi pair<int, int>
using namespace std;
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cout << vars << " = ";
string delim = "";
(..., (cout << delim << values, delim = ", "));
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
void enumerateSubmasks(int m)
{
// visits submasks without repetition and in descending order
for (int s = m;; s = (s - 1) & m)
{
if (s == 0)
{
//...
break;
}
}
}
int mpow(int a, int b, int m)
{
if (b == 0)
return 1;
int x = mpow(a, b / 2, m);
x = (x * x) % m;
if (b % 2)
{
x = (x * a) % m;
}
return x;
}
void printBinaryString(int n)
{
vi temp;
while (n)
{
if (n & 1)
temp.pb(1);
else
temp.pb(0);
n = n >> 1;
}
reverse(temp.begin(), temp.end());
for (auto node : temp)
cout << node << " ";
cout << endl;
}
void readVector(vi &a)
{
int n = a.size();
rep(i, n) cin >> a[i];
}
int update(int s,int e,int qs,int qe,vi &seg,vi &lazy,int index){
if(lazy[index]!=-1){
seg[index] = 1;
if(s!=e){
}
lazy[index] = -1;
}
if(qs > e || qe < s) {
}
if(s >= qs && e <= qe){
}
int mid = (s+e)/2;
update(s,mid,qs,qe,seg,lazy,2*index);
update(s,mid,qs,qe,seg,lazy,2*index+1);
}
//vi primes;
//vi primesVisited(sz,-1);
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// for(int i = 2 ; i < sz ; i++){
// if(primesVisited[i]!=-1) continue;
// primes.pb(i);
// primesVisited[i] = i;
// for(int j = i*i ; j < sz ; j+=i) {
// if(primesVisited[j]==-1) primesVisited[j] = i;
// }
// }
int tc;
cin >> tc;
while(tc--){
int a,b;
cin >> a >> b;
// a -> alice, b -> bob
set<int> ways;
// 0 1 0 1 0 1...
// case 1
int oddPos,evenPos;
oddPos = (a+b)/2;
evenPos = ( a+ b - oddPos);
// ways for alice to cause problem, alice is 0
rep(i,oddPos + 1){
// alice wins in these many odd position
int ao,ae,bo,be;
ao = i;
ae = a - i;
bo = oddPos - ao;
be = evenPos - ae;
if((ae) < 0 || bo < 0 || be < 0) continue;
ways.insert( ( ao + be));
}
// ways for alice to cause problem, alice is 1
rep(i,evenPos + 1){
// alice wins in these many even position
int ao,ae,bo,be;
ae = i;
ao = a - i;
bo = oddPos - ao;
be = evenPos - ae;
if(ao < 0 || (ae) < 0 || bo < 0 || be < 0) continue;
ways.insert( ( ae + bo));
}
cout << ways.size() << endl;
for(auto node : ways) cout << node << " ";
cout << endl;
}
}
122A - Lucky Division | 1611C - Polycarp Recovers the Permutation |
432A - Choosing Teams | 758A - Holiday Of Equality |
1650C - Weight of the System of Nested Segments | 1097A - Gennady and a Card Game |
248A - Cupboards | 1641A - Great Sequence |
1537A - Arithmetic Array | 1370A - Maximum GCD |
149A - Business trip | 34A - Reconnaissance 2 |
59A - Word | 462B - Appleman and Card Game |
1560C - Infinity Table | 1605C - Dominant Character |
1399A - Remove Smallest | 208A - Dubstep |
1581A - CQXYM Count Permutations | 337A - Puzzles |
495A - Digital Counter | 796A - Buying A House |
67A - Partial Teacher | 116A - Tram |
1472B - Fair Division | 1281C - Cut and Paste |
141A - Amusing Joke | 112A - Petya and Strings |
677A - Vanya and Fence | 1621A - Stable Arrangement of Rooks |