description: Alice and Borys are playing tennis.
  
  A tennis match consists of games. In each game, one of the players is serving and the other one is receiving.
  
  Players serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vice versa.
  
  Each game ends with a victory of one of the players. If a game is won by the serving player, it's said that this player holds serve. If a game is won by the receiving player, it's said that this player breaks serve.
  
  It is known that Alice won a games and Borys won b games during the match. It is unknown who served first and who won which games.
  
  Find all values of k such that exactly k breaks could happen during the match between Alice and Borys in total.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.
  
  Each of the next t lines describes one test case and contains two integers a and b (0 ≤ a, b ≤ 10^5; a + b > 0) — the number of games won by Alice and Borys, respectively.
  
  It is guaranteed that the sum of a + b over all test cases does not exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case print two lines.
  
  In the first line, print a single integer m (1 ≤ m ≤ a + b + 1) — the number of values of k such that exactly k breaks could happen during the match.
  
  In the second line, print m distinct integers k_1, k_2, …, k_m (0 ≤ k_1 < k_2 < … < k_m ≤ a + b) — the sought values of k in increasing order.
  
  Example
  
  Input
  
  
  3
  2 1
  1 1
  0 5
  
  
  Output
  
  
  4
  0 1 2 3
  2
  0 2
  2
  2 3
  
  Note
  
  In the first test case, any number of breaks between 0 and 3 could happen during the match: 
  
    * Alice holds serve, Borys holds serve, Alice holds serve: 0 breaks; 
    * Borys holds serve, Alice holds serve, Alice breaks serve: 1 break; 
    * Borys breaks serve, Alice breaks serve, Alice holds serve: 2 breaks; 
    * Alice breaks serve, Borys breaks serve, Alice breaks serve: 3 breaks. 
  
  
  
  In the second test case, the players could either both hold serves (0 breaks) or both break serves (2 breaks).
  
  In the third test case, either 2 or 3 breaks could happen: 
  
    * Borys holds serve, Borys breaks serve, Borys holds serve, Borys breaks serve, Borys holds serve: 2 breaks; 
    * Borys breaks serve, Borys holds serve, Borys breaks serve, Borys holds serve, Borys breaks serve: 3 breaks. 
solution: #include <bits/stdc++.h>
  using namespace std;
  template <typename T>
  using vc = vector<T>;
  template <typename T>
  using vvc = vc<vc<T>>;
  template <class T>
  using vvvc = vector<vvc<T>>;
  template <class T>
  using vvvvc = vector<vvvc<T>>;
  template <typename T>
  using PQ = priority_queue<T, vc<T>, greater<T>>;
  using vi = vc<int>;
  using vl = vc<long long>;
  using vd = vc<double>;
  using vb = vc<bool>;
  const string YESNO[2] = {"NO", "YES"};
  const string YesNo[2] = {"No", "Yes"};
  const string yesno[2] = {"no", "yes"};
  void YES(bool t = 1) { cout << YESNO[t] << '\n'; }
  void NO(bool t = 1) { YES(!t); }
  void Yes(bool t = 1) { cout << YesNo[t] << '\n'; }
  void No(bool t = 1) { Yes(!t); }
  void yes(bool t = 1) { cout << yesno[t] << '\n'; }
  void no(bool t = 1) { yes(!t); }
  int scan() { return getchar(); }
  void scan(int &a) { cin >> a; }
  void scan(long long &a) { cin >> a; }
  void scan(char &a) { cin >> a; }
  void scan(double &a) { cin >> a; }
  void scan(string &a) { cin >> a; }
  template <class T, class S>
  void scan(pair<T, S> &p) {
    scan(p.first), scan(p.second);
  }
  template <class T>
  void scan(vector<T> &a) {
    for (auto &i : a) scan(i);
  }
  void out(int &a) { cout << a << '\n'; }
  void out(long long &a) { cout << a << '\n'; }
  void out(char &a) { cout << a << '\n'; }
  void out(double &a) { cout << a << '\n'; }
  void out(string &a) { cout << a << '\n'; }
  template <class T, class S>
  void out(pair<T, S> &p) {
    cout << p.first << " " << p.second << '\n';
  }
  template <class T>
  void out(vector<T> &a) {
    for (auto &i : a) out(i);
  }
  template <class T>
  void scan(T &a) {
    cin >> a;
  }
  void IN() {}
  template <class Head, class... Tail>
  void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
  }
  template <class T>
  void vout(vector<T> &a) {
    for (long long i = 0; i < (int)(a).size(); ++i) {
      if (i > 0) cout << " ";
      cout << a[i];
    }
    cout << '\n';
  }
  template <class T>
  void vvout(vvc<T> &a) {
    for (auto x : a) vout(x);
  }
  long long pow2(int i) { return 1LL << i; }
  int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
  int topbit(long long t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
  int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
  int lowbit(long long a) { return a == 0 ? 64 : __builtin_ctzll(a); }
  long long allbit(long long n) { return (1LL << n) - 1; }
  int popcount(signed t) { return __builtin_popcount(t); }
  int popcount(long long t) { return __builtin_popcountll(t); }
  bool ispow2(int i) { return i && (i & -i) == i; }
  template <class T>
  pair<T, T> operator-(const pair<T, T> &x, const pair<T, T> &y) {
    return pair<T, T>(x.first - y.first, x.second - y.second);
  }
  template <class T>
  pair<T, T> operator+(const pair<T, T> &x, const pair<T, T> &y) {
    return pair<T, T>(x.first + y.first, x.second + y.second);
  }
  template <class T>
  long long operator*(const pair<T, T> &x, const pair<T, T> &y) {
    return (long long)x.first * y.first + (long long)x.second * y.second;
  }
  template <class T1, class T2, class Pred = std::less<T2>>
  struct sort_pair_second {
    bool operator()(const std::pair<T1, T2> &left,
                    const std::pair<T1, T2> &right) {
      Pred p;
      return p(left.second, right.second);
    }
  };
  bool valid(long long h, long long w, long long mh, long long mw) {
    return h >= 0 && h < mh && w >= 0 && w < mw;
  }
  template <class T, class S>
  inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
  }
  template <class T, class S>
  inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
  }
  int MOD = 1e9 + 7;
  double EPS = 1e-6;
  int INF = 2000000005;
  long long INFF = 4000000000000000005LL;
  double PI = acos(-1);
  int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
  int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
  int rdx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  int rdy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  const int mod = MOD;
  const int MX = 400000;
  using uint = unsigned;
  using ull = unsigned long long;
  struct mint {
    uint x;
    mint() : x(0) {}
    mint(long long x) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(0) - *this; }
    mint operator~() const { return mint(1) / *this; }
    mint &operator+=(const mint &a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint &operator-=(const mint &a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }
    mint &operator*=(const mint &a) {
      x = (ull)x * a.x % mod;
      return *this;
    }
    mint &operator/=(const mint &a) {
      x = (ull)x * a.pow(mod - 2).x % mod;
      return *this;
    }
    mint operator+(const mint &a) const { return mint(*this) += a; }
    mint operator-(const mint &a) const { return mint(*this) -= a; }
    mint operator*(const mint &a) const { return mint(*this) *= a; }
    mint operator/(const mint &a) const { return mint(*this) /= a; }
    mint pow(long long t) const {
      if (!t) return 1;
      mint res = pow(t / 2);
      res *= res;
      return (t & 1) ? res * x : res;
    }
    bool operator<(const mint &a) const { return x < a.x; }
    bool operator==(const mint &a) const { return x == a.x; }
    bool operator!=(const mint &a) const { return x != a.x; }
  };
  istream &operator>>(istream &i, mint &a) {
    i >> a.x;
    return i;
  }
  ostream &operator<<(ostream &o, const mint &a) {
    o << a.x;
    return o;
  }
  long long modpow(long long a, long long b, long long Mod) {
    long long res = 1;
    for (a %= Mod; b; a = a * a % Mod, b >>= 1)
      if (b & 1) res = res * a % Mod;
    return res;
  }
  vector<int> ps, pf;
  void sieve(int mx) {
    pf = vector<int>(mx + 1);
    for (long long i = 0; i < mx + 1; ++i) pf[i] = i;
    for (int i = 2; i <= mx; ++i) {
      if (pf[i] == i) ps.push_back(i);
      for (int j = 0; j < (int)(ps).size() && ps[j] <= pf[i]; ++j) {
        int x = ps[j] * i;
        if (x > mx) break;
        pf[x] = ps[j];
      }
    }
  }
  vc<pair<int, int>> factor(int x) {
    if (x == 1) return {};
    vector<pair<int, int>> res(1, pair<int, int>(pf[x], 0));
    while (x != 1) {
      if (res.back().first == pf[x])
        res.back().second++;
      else
        res.push_back(pair<int, int>(pf[x], 1));
      x /= pf[x];
    }
    return res;
  }
  template <typename T>
  struct edge {
    int src, to;
    T cost;
    edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
    edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
    edge &operator=(const int &x) {
      to = x;
      return *this;
    }
    operator int() const { return to; }
  };
  template <typename T>
  using Edges = vector<edge<T>>;
  template <typename T>
  using WeightedGraph = vector<Edges<T>>;
  using UnweightedGraph = vector<vector<int>>;
  UnweightedGraph graph(int N, int M = -1, bool is_directed = false,
                        bool is_1origin = true) {
    UnweightedGraph g(N);
    if (M == -1) M = N - 1;
    for (int _ = 0; _ < M; _++) {
      int x, y;
      cin >> x >> y;
      if (is_1origin) x--, y--;
      g[x].push_back(y);
      if (!is_directed) g[y].push_back(x);
    }
    return g;
  }
  template <typename T>
  WeightedGraph<T> wgraph(int N, int M = -1, bool is_directed = false,
                          bool is_1origin = true) {
    WeightedGraph<T> g(N);
    if (M == -1) M = N - 1;
    for (int _ = 0; _ < M; _++) {
      int x, y;
      cin >> x >> y;
      T c;
      cin >> c;
      if (is_1origin) x--, y--;
      g[x].emplace_back(x, y, c);
      if (!is_directed) g[y].emplace_back(y, x, c);
    }
    return g;
  }
  vector<long long> dijkstra(WeightedGraph<long long> &g, int start = 0) {
    using P = pair<long long, int>;
    int N = (int)g.size();
    vector<long long> d(N, INFF);
    priority_queue<P, vector<P>, greater<P>> Q;
    d[start] = 0;
    Q.emplace(0, start);
    while (!Q.empty()) {
      P p = Q.top();
      Q.pop();
      int cur = p.second;
      if (d[cur] < p.first) continue;
      for (auto dst : g[cur]) {
        if (d[dst] == INFF || d[cur] + dst.cost < d[dst]) {
          d[dst] = d[cur] + dst.cost;
          Q.emplace(d[dst], dst);
        }
      }
    }
    return d;
  }
  void solve() {
    long long A, B;
    IN(A, B);
    if (A > B) swap(A, B);
    vl ans;
    unordered_map<long long, long long> m;
    for (long long i = 0; i <= A + B; ++i) {
      if (m[i]) continue;
      bool flag = false;
      long long a = (A + B) / 2, b = (A + B + 1) / 2;
      if (a - i == A && b + i == B)
        flag = true;
      else if (b - i == A && a + i == B)
        flag = true;
      else if (a - i == B && b + i == A)
        flag = true;
      else if (b - i == A && a + i == B)
        flag = true;
      else if (i % 2 == 0 && ((a == A && b == B) || (b == A && a == B)))
        flag = true;
      else if (A - (a - i) == B - (b + i))
        flag = true;
      else if (A - (b - i) == B - (a + i))
        flag = true;
      else if (B - (a - i) == A - (b + i))
        flag = true;
      else if (B - (b - i) == A - (a + i))
        flag = true;
      if (flag) {
        ans.push_back(i);
        long long c = min(A, B - i);
        for (long long j = i + 2; j <= i + c * 2; ++j) {
          if (m[j]) break;
          ans.push_back(j);
          m[j] = 1;
          j++;
        }
        m[i] = 1;
      }
    }
    sort(begin(ans), end(ans));
    cout << (int)(ans).size() << '\n';
    vout(ans);
  }
  int main() {
    cout.tie(nullptr);
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    int T;
    IN(T);
    while (T--) solve();
  }
  