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: import os
  import sys
  from io import BytesIO, IOBase
   
  BUFSIZE = 8192
   
   
  class FastIO(IOBase):
      newlines = 0
   
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
   
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
   
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
   
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
                        
              
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
          
  class RangeQuery:
      def __init__(self, data, func=min):
          self.func = func
          self._data = _data = [list(data)]
          i, n = 1, len(_data[0])
          while 2 * i <= n:
              prev = _data[-1]
              _data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
              i <<= 1
   
      def query(self, start, stop):
          """func of data[start, stop)"""
          depth = (stop - start).bit_length() - 1
          return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])
   
      def __getitem__(self, idx):
          return self._data[0][idx]
   
   
  def check(st, n, k):
      for i in range(n-k+1):
          g = st.query(i, i+k)
          if(g > 1):
              return True 
      return False
   
   
   
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  from collections import defaultdict,deque
  from math import ceil,floor,sqrt,log2,gcd,pi
  from heapq import heappush,heappop
  from fractions import Fraction
  from bisect import bisect_left,bisect,bisect_right
  from itertools import combinations_with_replacement,permutations
  import sys
  
  from copy import deepcopy
  abc='abcdefghijklmnopqrstuvwxyz'
  ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  
  
  for _ in range(int(input())):
      a,b=map(int,input().split())
      s=a+b
      ans=[]
      if a==b:
          for i in range(0,s+1,2):
              ans.append(i)
          print(len(ans))
          print(*ans)
          continue
      elif abs(a-b)==1:
          for i in range(0,s+1):
              ans.append(i)
          print(len(ans))
          print(*ans)
          continue
      elif a==0 or b==0:
          if s%2==0:
              print(1)
              print(s//2)
          else:
              print(2)
              print(s//2,(s//2)+1)
      else:
          if s%2==0:
              for i in range(s//2-min(a,b),s//2 + min(a,b)+1,2):
                  ans.append(i)
              print(len(ans))
              print(*ans)
          else:
              for i in range((s//2)-min(a,b),(s+1)//2+min(a,b)+1):
                  ans.append(i)
              print(len(ans))
              print(*ans)
          
              
              
              
          