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: /**
   * @author -- Sourav Joshi
   */
  
  //			               _,--"^^"-.,_
  //			         _.-"~^`~-.    .-~`^~"-._
  //			     ,="`"-._     .----.     _.-"`"=,
  //			    ;_       "-. (0 )( 0) .-"       _;
  //			   .' `~"=,_    '.\ \/ /.'    _,="~` `.
  //			   ;_       "-. _.-)  (-._ .-"       _;
  //			   : ^~"-.,___.'  (    )  `.___,.-"~^ ;
  //			   :        _:     `--'     :_        :
  //			    '._,-~"` :':          :': `"~-,_.'
  //			       '.,_.-`.            .'`-._,.'
  //			          :__.-`-.______.-'`-.__;
  //			                 //    \\
  //			               (((~    ~)))
  
  import java.util.*;
  
  
  import static java.lang.Math.max;
  import static java.lang.Math.min;
  import static java.lang.Math.abs;
  import static java.lang.Math.ceil;
  import static java.lang.Math.max;
  import static java.lang.Math.pow;
  import java.io.*;
  
  public class Solution {
  
  	static FastScanner s = new FastScanner();
  	static FastWriter out = new FastWriter();
  	final static long mod = 1000000000 + 7;
  	final static int INT_MAX = Integer.MAX_VALUE;
  	final static int INT_MIN = Integer.MIN_VALUE;
  	final static long LONG_MAX = Long.MAX_VALUE;
  	final static long LONG_MIN = Long.MIN_VALUE;
  	final static double DOUBLE_MAX = Double.MAX_VALUE;
  	final static double DOUBLE_MIN = Double.MIN_VALUE;
  	final static float FLOAT_MAX = Float.MAX_VALUE;
  	final static float FLOAT_MIN = Float.MIN_VALUE;
  
  
  	static class Pair<T,R>{
  		T first;
  		R Second;
  	}
  
  	static class FastScanner{
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FastScanner() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
  
  		String next(){
  			while (st == null || !st.hasMoreElements()){
  				try{
  					st = new StringTokenizer(br.readLine());
  				}catch (IOException  e){
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  		int nextInt(){
  			return Integer.parseInt(next());
  		}
  		long nextLong(){
  			return Long.parseLong(next());
  		}
  
  		double nextDouble(){
  			return Double.parseDouble(next());
  		}
  		String nextLine(){
  			String str = "";
  			try{
  				str = br.readLine();
  			}
  			catch (IOException e){
  				e.printStackTrace();
  			}
  			return str;
  		}
  	}
  
  	static class FastWriter{
  		private final BufferedWriter bw;
  
  		public FastWriter() {
  			this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
  		}
  
  		public void print(Object object) throws IOException{
  			bw.append(""+ object);
  		}
  
  		public void println(Object object) throws IOException{
  			print(object);
  			bw.append("\n");
  		}
  
  		public void close() throws IOException{
  			bw.close();
  		}
  	}
  
  	public static void f(int arr[], int n, int b, int i, Set<Integer> ans) {
  		if(i == arr.length) {
  			if(n == 0) {
  				ans.add(b);
  				return;
  			}else {
  				return;
  			}
  		}
  		
  		if(i%2 == 0) {
  			arr[i] = 1;
  			f(arr, n-1, b, i+1, ans);
  			arr[i] = 0;
  			f(arr, n, b+1, i+1, ans);
  			arr[i] = 0;
  		}else {
  			arr[i] = 1;
  			f(arr, n-1, b+1, i+1, ans);
  			arr[i] = 0;
  			f(arr, n, b, i+1, ans);
  			arr[i] = 0;
  		}
  		
  	}
  	
  	
  	
  	public static void s(int arr[], int n, int b, int i, Set<Integer> ans) {
  		if(i == arr.length) {
  			if(n == 0) {
  				ans.add(b);
  				return;
  			}else {
  				return;
  			}
  		}
  		
  		if(i%2 == 1) {
  			arr[i] = 1;
  			s(arr, n-1, b, i+1, ans);
  			arr[i] = 0;
  			s(arr, n, b+1, i+1, ans);
  			arr[i] = 0;
  		}else {
  			arr[i] = 1;
  			s(arr, n-1, b+1, i+1, ans);
  			arr[i] = 0;
  			s(arr, n, b, i+1, ans);
  			arr[i] = 0;
  		}
  		
  	}
  
  	
  
  	public static void main(String[] args) throws IOException {
  		int test = s.nextInt();
  		while(test-->0) {
  			int a = s.nextInt();
  			int b = s.nextInt();
  			int total = a+b;
  			int op1 = total/2;
  			int op2 = total-op1;
  			Set<Integer> ans = new HashSet<Integer>();
  			for(int i = 0; i <= op1; i++) {
  				if((op2 + i >= a) && i <= a) {
  					int br = (op1 - i) + (a - i);
  					ans.add(br);
  				}
  			}
  			for(int i = 0; i <= op2; i++) {
  				if((op1 + i >= a) && i <= a) {
  					int br = (op2 - i) + (a - i);
  					ans.add(br);
  				}
  			}
  			out.println(ans.size());
  			ArrayList<Integer> list = new ArrayList<>();
  			for(int i : ans) {
  				list.add(i);
  			}
  			Collections.sort(list);
  			for(int i : list) {
  				out.print(i+" ");
  			}
  			out.println("");
  		}
  		out.close();
  	}
  
  	public static long gcd(long a, long b){
  		if(a > b)
  			a = (a+b)-(b=a);
  		if(a == 0L)
  			return b;
  		return gcd(b%a, a);
  	}
  
  	public static boolean isPrime(long n){
  		if(n < 2) return false;
  		if(n == 2 || n == 3) return true;
  		if(n%2 == 0 || n%3 == 0) return false;
  		long sqrtN = (long)Math.sqrt(n)+1;
  		for(long i = 6L; i <= sqrtN; i += 6) {
  			if(n%(i-1) == 0 || n%(i+1) == 0) return false;
  		}
  		return true;
  	}
  
  	public static ArrayList<Integer> findDiv(int N){
  		//gens all divisors of N
  		ArrayList<Integer> ls1 = new ArrayList<Integer>();
  		ArrayList<Integer> ls2 = new ArrayList<Integer>();
  		for(int i=1; i <= (int)(Math.sqrt(N)+0.00000001); i++)
  			if(N%i == 0)
  			{
  				ls1.add(i);
  				ls2.add(N/i);
  			}
  		Collections.reverse(ls2);
  		for(int b: ls2)
  			if(b != ls1.get(ls1.size()-1))
  				ls1.add(b);
  		return ls1;
  	}
  
  	public static long power(long x, long y, long p){
  		//0^0 = 1
  		long res = 1L;
  		x = x%p;
  		while(y > 0)
  		{
  			if((y&1)==1)
  				res = (res*x)%p;
  			y >>= 1;
  		x = (x*x)%p;
  		}
  		return res;
  	}
  
  	public static void printintarr(int[] arr) {
  		for(int i = 0; i < arr.length; i++) {
  			System.out.print(arr[i]+" ");
  		}
  	}
  
  	public static void printlongarr(long[] arr) {
  		for(int i = 0; i < arr.length; i++) {
  			System.out.print(arr[i]+" ");
  		}
  	}
  
  	public static void printdoublearr(double[] arr) {
  		for(int i = 0; i < arr.length; i++) {
  			System.out.print(arr[i]+" ");
  		}
  	}
  
  	public static void printintarr(int arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				System.out.print(arr[i][j]+" ");
  			}
  			System.out.println();
  		}
  	}
  
  	public static void printlongarr(long arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				System.out.print(arr[i][j]+" ");
  			}
  			System.out.println();
  		}
  	}
  
  	public static void printdoublearr(double arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				System.out.print(arr[i][j]+" ");
  			}
  			System.out.println();
  		}
  	}
  
  	public static void takeintarr(int arr[]) {
  		for(int i = 0; i < arr.length; i++) {
  			arr[i] = s.nextInt();
  		}
  	}
  
  	public static void takeintarr(int arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				arr[i][j] = s.nextInt();
  			}
  		}
  	}
  }