#include <bits/stdc++.h>
using namespace std;
void file_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int64_t INF = 1e17;
const int64_t mod = 1e9 + 7;
const int N = 1e5 + 5, M = N;
const long double EulerMascheroni = 0.57721566490153286060651;
inline int64_t mul(int64_t a, int64_t b) { return (INF / a > b ? a * b : INF); }
void solve(int x) {
  int a, b;
  cin >> a >> b;
  int d = abs(a - b) / 2;
  int y = d;
  vector<int> ans;
  while (y <= a + b - d) {
    if ((a + b) % 2) {
      ans.push_back(y);
      y++;
    } else {
      ans.push_back(y);
      y += 2;
    }
  }
  cout << (int)((ans).size()) << endl;
  for (long long z = 0; z <= (int)((ans).size()) - 1; z++)
    cout << (ans[z]) << " ";
  cout << "\n";
  ;
}
int main(int argc, char const *argv[]) {
  clock_t begin = clock();
  file_io();
  int TC;
  cin >> TC;
  int i = 1;
  while (i <= TC) {
    solve(i);
    i++;
  }
  return 0;
}
