#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b;
  cin >> a >> b;
  int total = a + b;
  int f = total / 2;
  int s = total - f;
  set<int> st;
  for (int i = 0; i <= min(a, f); i++) {
    if (a - i <= s) st.insert(a - i + f - i);
  }
  for (int i = 0; i <= min(a, s); i++) {
    if (a - i <= f) st.insert(a - i + s - i);
  }
  cout << st.size() << endl;
  for (auto it : st) cout << it << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
