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 java.util.*;
  import java.io.*;
  import java.lang.*;
  import java.math.BigInteger;
  
  public class A {
  
  	static FastReader		sc	= new FastReader();
  	static PrintWriter	out	= new PrintWriter(System.out);
  
  
  	public static void main(String[] args) throws Exception {
  
  		int t = sc.ni();
  		while (t-- > 0) {
  			A.go();
  		}
  		out.flush();
  
  	}
  
  	// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
  
  static void go() {
  	int a=sc.ni(),b=sc.ni();
  	int m=a+b;
  
  	ArrayList<Integer> ans=new ArrayList<>();
  	if(a==b) {
  		for(int i=0;i<=m;i+=2) {
  			ans.add(i);
  		}
  		out.println(ans.size());
  		for(int i:ans) {
  			out.print(i+" ");
  		}
  		out.println();
  		return;
  	}
  	if(b+1==a||(a+1)==b) {
  		for(int i=0;i<=m;i+=1) {
  			ans.add(i);
  		}
  		out.println(ans.size());
  		for(int i:ans) {
  			out.print(i+" ");
  		}
  		out.println();
  		return;
  	}
  	if(b==0) {
  
  		if(m/2==(m+1)/2) {
  			out.println(1);
  			out.println(m/2);
  		}else {
  			out.println(2);
  			out.println(m/2+" "+(m+1)/2);
  		}
  		return;
  	}
  	int s1=m/2,s2=m-s1;  // alice serves , bob serves
  	//let x be the times bob breaks the serves and y be the times alice breaks the serves so a=(s1-x)+y
  	// b=(s2-y)+x      y=a-(s1-x)   putting y in equation 2 should give b for valid breaks.
  	// iterating through all values of x
  	
  	TreeSet<Integer> set=new TreeSet<>();
  	for(int i=0;i<=s1;i++) {
  		if((a-(s1-i))>=0&&(a-(s1-i))<=s2){
  			set.add(i+(a-(s1-i)));
  		}
  	}
  	for(int i=0;i<=s2;i++) {
  		if((a-(s2-i))>=0&&(a-(s2-i))<=s1){
  			set.add(i+(a-(s2-i)));
  		}
  	}
  
  	out.println(set.size());
  	for(int i:set) {
  		out.print(i+" ");
  	}
  	out.println();
  	
  }
  
  	// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
  	static long	fact[];
  	static long	invfact[];
  
  	static long ncr(int n, int k) {
  		if (k < 0 || k > n) {
  			return 0;
  		}
  		long x = fact[n] % mod;
  		long y = invfact[k] % mod;
  		long yy = invfact[n - k] % mod;
  		long ans = (x * y) % mod;
  		ans = (ans * yy) % mod;
  		return ans;
  	}
  
  	static long gcd(long a, long b) {
  		if (b == 0) {
  			return a;
  		}
  		return gcd(b, a % b);
  	}
  
  	static int	prime[]	= new int[200005];
  	static int	N				= 200005;
  
  	static void sieve() {
  
  		for (int i = 0; i < N; i++) {
  			prime[i] = i;
  		}
  		for (int i = 2; i * i <= N; i++) {
  			if (prime[i] == i) {
  				prime[i] = i;
  				for (int j = i; j < N; j += i) {
  					prime[j] = i;
  				}
  			}
  		}
  	}
  
  	static int gcd(int a, int b) {
  		if (b == 0) {
  			return a;
  		}
  		return gcd(b, a % b);
  	}
  
  	static void sort(int[] a) {
  		ArrayList<Integer> aa = new ArrayList<>();
  		for (Integer i : a) {
  			aa.add(i);
  		}
  		Collections.sort(aa);
  		for (int i = 0; i < a.length; i++)
  			a[i] = aa.get(i);
  	}
  
  	static void sort(long[] a) {
  		ArrayList<Long> aa = new ArrayList<>();
  		for (Long i : a) {
  			aa.add(i);
  		}
  		Collections.sort(aa);
  		for (int i = 0; i < a.length; i++)
  			a[i] = aa.get(i);
  	}
  
  	static int mod = (int) 1000000007;
  
  	static long pow(long x, long y) {
  		long res = 1l;
  		while (y != 0) {
  			if (y % 2 == 1) {
  				res = (x % mod * res % mod) % mod;
  			}
  			y /= 2;
  			x = (x % mod * x % mod) % mod;
  		}
  		return res % mod;
  	}
  
  	// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fast IO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
  
  	static class FastReader {
  		BufferedReader	br;
  		StringTokenizer	st;
  
  		public FastReader() {
  			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 ni() {
  			return Integer.parseInt(next());
  		}
  
  		long nl() {
  			return Long.parseLong(next());
  		}
  
  		double nextDouble() {
  			return Double.parseDouble(next());
  		}
  
  		int[] intArray(int n) {
  			int a[] = new int[n];
  			for (int i = 0; i < n; i++)
  				a[i] = sc.ni();
  			return a;
  		}
  
  		long[] longArray(int n) {
  			long a[] = new long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = sc.nl();
  			return a;
  		}
  
  		String nextLine() {
  			String str = "";
  			try {
  				str = br.readLine();
  			} catch (IOException e) {
  				e.printStackTrace();
  			}
  			return str;
  		}
  	}
  }
  