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.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.StringTokenizer;
  
  
  public class CharmedByTheGame {
  
  	
  		//2d arraylist adj list
  	//ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
  	//for (int i = 0; i < n; i++)adj.add(new ArrayList<Integer>());
  	/*
  	 -Binary search
  	 int lo = 0;
  	 int hi = highest val possible;
  	 while (lo <= hi){
  	 int mid = (lo+hi)/2;
  	 
  	 if (check){
  	 
  	 	}else {
  	 	
  	 	}
  	 }
  	 */
  		
  		
  		
  	//Custom Comparators
  	/*
  	 //ArrayList<comp> a = new ArrayList<comp>();
  	 //long [] a = new new long [n];
  	 
  	 class comp implements Comparable<comp> {
  
  		public int a, b;
  
  		public comp(int a, int b) {
  			this.a = b;
  			this.a = b;
  		}
  
  		public int compareTo(comp other) {
  		//sort by 1 criteria
  		 //return Integer.compare(this.a. other.a);
  		  
  		  //sort by 2 criteria
  			//if (this.a != other.a) {
  			//	return Integer.compare(this.a, other.a);
  			//} else {
  				return Integer.compare(other.b, this.b);
  			//}
  		}
  	}
  	 */
  		
  		
  		
  	//MultiSet
  	/*
  	 static void add(int x){
  		if(multiset.containsKey(x)){
  			multiset.put(x, multiset.get(x) + 1);
  		} else {
  			multiset.put(x, 1);
  		}
  	}
  
  	static void remove(int x){
  		multiset.put(x, multiset.get(x) - 1);
  		if(multiset.get(x) == 0){
  			multiset.remove(x);
  		}
  	}
  	 */
  	 
  		
  	//DFS and other related items
  	//ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
  	//for (int i = 0; i < n; i++)adj.add(new ArrayList<Integer>());
  	//boolean [] visited = new boolean [n];
  	/*
  	 static void dfs(int node) {
  			if (visited[node]) return;
  			
  			nodes++;
  			visited[node] = true;
  			for (int neighbor : adj.get(node)) {
  				dfs(neighbor);
  			}
  	 */
  	 
  
  		
  	//Floodfill
  	/*
  	 static void floodfill(int r, int c, char curC) {
  		if (r < x || r >= 0 || c < y || c >= 0) {
  			return;
  		} 
  		if(visited[r][c] || grid[r][c] != curC) {
  			return;
  		}
  		visited[r][c] = true;
  		size++;
  		
  		floodfill(r+1, c, curC);
  		floodfill(r-1, c, curC);
  		floodfill(r, c+1, curC);
  		floodfill(r, c-1, curC);
  	}
  	 */
  		
  		
  	//2 pointers
  	/*
  	 int l = 0, r = 0, cur = 0, ans = 0;
  			while (l < n && r < n) {
  				while (r < n) {
  					r++;
  					if ((check condition)) {
  						r--;
  						break;
  					}
  				}
  
  				l++;
  			}
  	 */
  		
  		
  	//mod int template
  		/*static int mod(int a, int m)
  	{
  	    return (a%m + m) % m;
  	}*/
  		
  		
  		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 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;
  	        }
  	    }
  		
  		
  		
  		public static void main(String[] args) throws IOException {
  			PrintWriter out = new PrintWriter(System.out);
  			FastReader in = new FastReader();
  			 int t = in.nextInt();
  
  			 for (int ie = 0; ie < t; ie++) {
  			 int a = in.nextInt();
  			 int b = in.nextInt();
  			 int t1 = (int)Math.ceil((double)(a+b)/2);
  			 int t2 = (a+b)/2;
  			 int Aturn = 0;
  			 int Bturn = 0;
  			 Aturn = t1;
  			 Bturn = t2;
  			 ArrayList<Integer> ans = new ArrayList<Integer>();
  			 HashMap<Integer, Integer> hs = new HashMap<Integer, Integer>();
  			 int temp = 0;
  			 if (Aturn < a) {
  				 temp = a-Aturn;
  				 Aturn += temp;
  				 Bturn -= temp;
  				 if(hs.get(temp) == null) {
  				 ans.add(temp);
  				 hs.put(temp, 1);
  				 }
  			 }else if (Bturn < b) {
  				 temp = b-Bturn;
  				 Bturn += temp;
  				 Aturn -= temp;
  				 if(hs.get(temp) == null) {
  					 ans.add(temp);
  					 hs.put(temp, 1);
  				 }
  			 }else {
  				 if(hs.get(temp) == null) {
  					 ans.add(temp);
  					 hs.put(temp, 1);
  				 }
  			 }
  			 int curAns = temp;
  			 int min = Math.min(a, b);
  			 while(min != 0 && curAns <= a+b) {
  				 if (hs.get(curAns+2) == null && curAns+2 <= a+b){
  					 ans.add(curAns+2);
  					 hs.put(curAns+2, 1);
  				 }
  				 curAns+=2;
  				 min--;
  			 }
  			 
  			 Aturn = t2;
  			 Bturn = t1;
  			
  			 if (Aturn < a) {
  				  temp = a-Aturn;
  				 Aturn += temp;
  				 Bturn -= temp;
  				 if(hs.get(temp) == null) {
  					 ans.add(temp);
  					 hs.put(temp, 1);
  				 }
  			 }else if (Bturn < b) {
  				  temp = b-Bturn;
  				 Bturn += temp;
  				 Aturn -= temp;
  				 if(hs.get(temp) == null) {
  					 ans.add(temp);
  					 hs.put(temp, 1);
  				 }
  			 }else {
  				 temp = 0;
  				 if(hs.get(temp) == null) {
  					 ans.add(temp);
  					 hs.put(temp, 1);
  				 }
  				 
  			 }
  			  curAns = temp;
  			  min = Math.min(a, b);
  			 while(min != 0 && curAns <= a+b) {
  				 if (hs.get(curAns+2) == null && curAns+2 <= a+b){
  					 ans.add(curAns+2);
  					 hs.put(curAns+2, 1);
  				 }
  				 curAns+=2;
  				 min--;
  			 }
  			 Collections.sort(ans);
  			 
  			 out.println(ans.size());
  			 for(int i = 0; i < ans.size(); i++) {
  				 out.print(ans.get(i)+" ");
  			 }
  			 out.println();
  			 }
  			 out.close();
  	}
  
  }
  