#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long infinity = 1e18;
void solve() {
  long long a, b;
  cin >> a >> b;
  long long n = a + b;
  if (n % 2 == 0) {
    long long a1 = max(a, b);
    long long b1 = min(a, b);
    long long mi = a1 - n / 2;
    long long ma = n - mi;
    long long ans = (ma - mi) / 2 + 1;
    cout << ans << "\n";
    for (long long i = mi; i <= ma; i += 2) {
      cout << i << " ";
    }
    cout << "\n";
  } else {
    long long a1 = max(a, b);
    long long b1 = min(a, b);
    long long k1 = n / 2 + 1;
    long long k2 = n - k1;
    long long mi = a1 - k1;
    long long ma = n - mi;
    long long ans = ma - mi + 1;
    cout << ans << "\n";
    for (long long i = mi; i <= ma; i++) {
      cout << i << " ";
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
