#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    if ((a + b) % 2 == 1) {
      cout << ((a + b + 1) / 2 + a) - ((a + b) / 2 - a) + 1 << endl;
      for (int i = (a + b) / 2 - a; i <= (a + b + 1) / 2 + a; i++)
        cout << i << ' ';
      cout << endl;
    } else {
      cout << (((a + b) / 2 + a) - ((a + b) / 2 - a)) / 2 + 1 << endl;
      for (int i = (a + b) / 2 - a; i <= (a + b) / 2 + a; i += 2)
        cout << i << ' ';
      cout << endl;
    }
  }
  return 0;
}
