#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long int factorial(long long int n) {
  if (n == 1 || n == 0) {
    return 1;
  } else {
    return n * factorial(n - 1);
  }
}
void solve();
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  long long int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << (a + b) / 2 + 1 << endl;
    for (long long int i = 0; i <= a + b; i = i + 2) {
      cout << i << " ";
    }
    cout << endl;
  } else {
    vector<long long int> v;
    map<long long int, long long int> mp;
    long long int diff = abs(b - a);
    if (diff % 2 == 0) {
      long long int q = diff / 2;
      v.push_back(q);
      mp[q]++;
      for (long long int i = 0; i <= 2 * min(a, b); i = i + 2) {
        mp[q + i]++;
        if (mp[q + i] == 1) {
          v.push_back(q + i);
        }
      }
    } else {
      long long int q = diff / 2;
      long long int p = q + 1;
      mp[q]++;
      mp[p]++;
      v.push_back(q);
      v.push_back(p);
      for (long long int i = 0; i <= 2 * min(a, b); i = i + 2) {
        mp[q + i]++;
        mp[p + i]++;
        if (mp[q + i] == 1) {
          v.push_back(q + i);
        }
        if (mp[p + i] == 1) {
          v.push_back(p + i);
        }
      }
    }
    cout << v.size() << endl;
    for (long long int i = 0; i < v.size(); i++) {
      cout << v[i] << " ";
    }
    cout << endl;
  }
}
