#include <bits/stdc++.h>
using namespace std;
void main2() {
  long long int a, b, n, t, x, p, q;
  cin >> a >> b;
  if (a < b) swap(a, b);
  vector<long long int> ans;
  t = (a + b) / 2;
  if ((a + b) % 2 == 1) t++;
  p = min(t, a);
  q = min(a + b - t, b);
  for (long long int i = 0; i <= q; i++) ans.push_back(p - q + 2 * i);
  if ((a + b) % 2 == 1) {
    p = min(a + b - t, a);
    q = min(t, b);
    if (q > p) swap(p, q);
    for (long long int i = 0; i <= q; i++) ans.push_back(p - q + 2 * i);
  }
  cout << ans.size() << "\n";
  sort(ans.begin(), ans.end());
  for (long long int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  for (long long int i = 1; i <= t; i++) {
    main2();
  }
  return 0;
}
