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.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Complete search


Solutions:
def print_breaks(a, b):
	(a, b) = (min(a, b), max(a, b))
	x = b - a
	if x % 2 == 1:
		y = (x - 1) // 2
		res = list([str(el) for el in range(y, a * 2 + y + 2)])
	else:
		y = x // 2
		res = list([str(el) for el in range(y, 2 * a + y + 1, 2)])
	print(len(res))
	print(' '.join(res))
t = int(input())
for i in range(t):
	s = input()
	(a, b) = s.split(' ')
	(a, b) = (int(a), int(b))
	print_breaks(a, b)


from collections import Counter
import math

def getlist():
	return list(map(int, input().split()))

def maplist():
	return map(int, input().split())

def ceiling(n):
	if int(n) - n == 0:
		n = int(n)
	else:
		n = int(n) + 1
	return n

def main():
	t = int(input())
	for _ in range(t):
		(a, b) = maplist()
		box = []
		y = (a + b) // 2
		x = a + b - y
		if abs(a - b) <= 1:
			box.append(0)
		i = 0
		box = []
		if a + b == 1:
			box.append(1)
		k = 0
		for num in range(a + b):
			m = max(a, b)
			n = min(a, b)
			if x - i + num == m and num <= y and (i <= x) and (y - num + i == n):
				box.append(num + i)
				i += 1
			if x - num + k == n and num <= x and (k <= y) and (y + num - k == m):
				box.append(num + k)
				k += 1
		box = list(set(box))
		print(len(box))
		print(*sorted(box))
main()


t = int(input())
for i in range(t):
	(a, b) = [int(c) for c in input().split(' ')]
	n = a + b
	if n % 2:
		s_set = [int(n / 2), int(n / 2) + 1]
	else:
		s_set = [int(n / 2)]
	output_set = set()
	for s in s_set:
		mn = max(0, b - s)
		mx = min(b, n - s)
		output_set.update([2 * rb + s - b for rb in range(mn, mx + 1)])
	print(len(output_set))
	l = list(output_set)
	l.sort()
	ll = [str(c) for c in l]
	print(' '.join(ll))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	d = (max(a, b) - min(a, b)) // 2
	if (a + b) % 2 == 1:
		print(a + b - d + 1 - d)
		for i in range(d, a + b + 1 - d):
			if i == a + b - d:
				print(i)
				continue
			print(i, end=' ')
	else:
		print((a + b - d - d + 1 + 1) // 2)
		for i in range(d, a + b + 1 - d, 2):
			if i == a + b - d:
				print(i)
				continue
			print(i, end=' ')


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	ans = []
	tot = a + b
	x = tot // 2
	s = tot - x
	for i in range(min(x, a) + 1):
		if a - i <= s:
			ans.append(a - i + x - i)
	for i in range(min(a, s) + 1):
		if a - i <= x:
			ans.append(a - i + s - i)
	print(len(set(ans)))
	print(*sorted(set(ans)))


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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def intArr():
	return map(int, input().split())

def In():
	return int(input())

def func():
	(a, b) = intArr()
	ans = set()
	n = a + b
	serve_2 = n // 2
	serve_1 = n - serve_2
	for i in range(serve_1 + 1):
		if 0 <= a + i - serve_1 <= serve_2:
			ans.add(2 * i + a - serve_1)
	(serve_1, serve_2) = (serve_2, serve_1)
	for i in range(serve_1 + 1):
		if 0 <= a + i - serve_1 <= serve_2:
			ans.add(2 * i + a - serve_1)
	print(len(ans))
	return sorted(ans)

def main():
	for _ in range(In()):
		print(*func())
	return
main()


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	s = a + b
	x = s // 2
	if s % 2 == 0:
		ans = [i for i in range(b - x, x + a + 1, 2)]
	else:
		ans = [i for i in range(b - x - 1, x + a + 2)]
	print(len(ans))
	print(*ans)
	t -= 1


def run():
	n = int(input())
	for i in range(n):
		(a, b) = input().split(' ')
		a = int(a)
		b = int(b)
		min1 = 999999
		max1 = 0
		na = a + b - int((a + b) / 2)
		for x in range(max(na - b, 0), min(a, na) + 1, 1):
			brks = na + a - 2 * x
			if brks < 0:
				break
			if brks < min1:
				min1 = brks
			if brks > max1:
				max1 = brks
		if (a + b) % 2 == 0:
			L = [i for i in range(min1, max1 + 2, 2)]
			L.sort()
			print(len(L))
			printp(L)
		else:
			min2 = 999999
			max2 = 0
			na = a + b - na
			for x in range(max(na - b, 0), min(a, na) + 1, 1):
				brks = na + a - 2 * x
				if brks < 0:
					break
				if brks < min2:
					min2 = brks
				if brks > max2:
					max2 = brks
			L = [i for i in range(min1, max1 + 2, 2)]
			K = [i for i in range(min2, max2 + 2, 2)] + L
			K.sort()
			print(len(K))
			printp(K)

def printp(X):
	for i in X:
		print(i, end=' ')
	print()
run()


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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from itertools import permutations
from collections import *
from collections import deque
from operator import itemgetter, attrgetter
from decimal import *
import bisect
import math
import heapq as hq
MOD = 10 ** 9 + 7

def is_prime(n):
	if n == 2 or n == 3:
		return True
	if n < 2 or n % 2 == 0:
		return False
	if n < 9:
		return True
	if n % 3 == 0:
		return False
	r = int(n ** 0.5)
	f = 5
	while f <= r:
		if n % f == 0:
			return False
		if n % (f + 2) == 0:
			return False
		f += 6
	return True

def pow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % m
		b //= 2
		a = a * a % m
	return ans

def ispalindrome(s):
	if s[:] == s[::-1]:
		return 1
	return 0
dp = []
limit = []
v = []

def dpdfs(u, t=-1):
	dp[0][u] = 0
	dp[1][u] = 0
	for i in v[u]:
		if i == t:
			continue
		if dp[1][i] == -1:
			dpdfs(i, u)
		dp[0][u] += max(abs(limit[0][u] - limit[1][i]) + dp[1][i], abs(limit[0][u] - limit[0][i]) + dp[0][i])
		dp[1][u] += max(abs(limit[1][u] - limit[1][i]) + dp[1][i], abs(limit[1][u] - limit[0][i]) + dp[0][i])
vis = []
f = 0

def dfs(i):
	vis[i] = 1
	act[i] = 1
	for j in v[i]:
		if act[j]:
			f = 1
			return -1
		if vis[j] == 0:
			if dfs(j) == -1:
				return -1
	act[i] = 0
	ans.append(i)
	return 0
from queue import PriorityQueue

def z_algorithm(s):
	res = [0] * len(s)
	res[0] = len(s)
	(i, j) = (1, 0)
	while i < len(s):
		while i + j < len(s) and s[j] == s[i + j]:
			j += 1
		res[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < len(s) and k + res[k] < j:
			res[i + k] = res[k]
			k += 1
		(i, j) = (i + k, j - k)
	return res

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a / gcd(a, b) * b

def gcdExtended(a, b):
	if a == 0:
		return (b, 0, 1)
	(gcd, x1, y1) = gcdExtended(b % a, a)
	x = y1 - b // a * x1
	y = x1
	return (gcd, x, y)
import re
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b < a:
		(a, b) = (b, a)
	ans = []
	total = a + b
	for i in range(a + 1):
		ans.append(a - i + (total + 1) // 2 - i)
		if total % 2:
			ans.append(a - i + total // 2 - i)
	ans = list(set(ans))
	ans.sort()
	print(len(ans))
	print(*ans)


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	(wa, wb) = [int(i) for i in input().split()]
	if wa > wb:
		(wa, wb) = (wb, wa)
	n = wa + wb
	ans = []
	for i in range(n // 2 - wa, n // 2 + wa + 1 + n % 2, 1 + 1 - n % 2):
		ans.append(i)
	print(len(ans))
	print(*ans)


import math
from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, gcd
import bisect
import sys
import random
import heapq

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def main():
	for _ in range(int(input())):
		(a, b) = get_ints()
		(a, b) = (max(a, b), min(a, b))
		n = a + b
		ans = []
		for i in range(a + 1):
			if n % 2 == 0:
				if i <= n // 2:
					if b >= n // 2 - i:
						max_not_order_b = n // 2 - i
						max_not_order_a = a - i
						ans.append(max_not_order_a + max_not_order_b)
					else:
						max_not_order_b = b
						max_not_order_a = a - i - (n // 2 - i - b)
						ans.append(max_not_order_a + max_not_order_b)
			else:
				if i <= n // 2:
					if b >= n // 2 - i:
						max_not_order_b = n // 2 - i
						max_not_order_a = a - i
						ans.append(max_not_order_a + max_not_order_b)
					else:
						max_not_order_b = b
						max_not_order_a = a - i - ((n + 1) // 2 - i - b)
						ans.append(max_not_order_a + max_not_order_b)
				if i <= (n + 1) // 2:
					if b >= (n + 1) // 2 - i:
						max_not_order_b = (n + 1) // 2 - i
						max_not_order_a = a - i
						ans.append(max_not_order_a + max_not_order_b)
					else:
						max_not_order_b = b
						max_not_order_a = a - i - (n // 2 - i - b)
						ans.append(max_not_order_a + max_not_order_b)
		ans = sorted(set(ans))
		print(len(ans))
		print(*ans)
main()


import os, sys, math
from io import BytesIO, IOBase
ip = lambda : input()
it = lambda : int(input())
ma = lambda : map(int, input().split(' '))
li = lambda : list(map(int, input().split(' ')))
mod = 10 ** 9 + 7

def f(a, b):
	s = set()
	breaks = 0
	matches = a + b
	ace = matches // 2
	if matches % 2:
		ace += 1
	bce = matches - ace
	while breaks <= bce:
		akeep = a - breaks
		bkeep = bce - breaks
		bbreaks = ace - akeep
		if bkeep >= 0 and bbreaks >= 0 and (akeep >= 0):
			s.add(breaks + bbreaks)
		breaks += 1
	(ace, bce) = (bce, ace)
	breaks = 0
	while breaks <= bce:
		akeep = a - breaks
		bkeep = bce - breaks
		bbreaks = ace - akeep
		if bkeep >= 0 and bbreaks >= 0 and (akeep >= 0):
			s.add(breaks + bbreaks)
		breaks += 1
	return s

def main():
	for _ in range(int(input())):
		(a, b) = ma()
		ans = list(f(a, b))
		print(len(ans))
		ans.sort()
		print(*ans)
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from itertools import product, permutations, combinations, accumulate, compress
import os, sys
input = lambda : sys.stdin.buffer.readline().rstrip(b'\r\n')

def dbp(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)
a_str = lambda : input().decode('ascii')
get_int_list = lambda : [int(x) for x in input().split()]
join_str = lambda l, ch=' ': ch.join((str(x) for x in l))

def do_thing():
	(b, a) = sorted(get_int_list())
	n = a + b

	def slow_solve():
		dbp('case:', a, b)
		ans = []
		for p in product((0, 1), repeat=n):
			score = [0] * 2
			for i in range(n):
				turn = i % 2
				if not p[i]:
					score[turn] += 1
				else:
					score[1 - turn] += 1
			if [a, b] == score or [b, a] == score:
				dbp('added:', p, score)
				ans.append(sum(p))
		return join_str(sorted(set(ans)))
	a0 = (n + 1) // 2
	agap = a - a0
	b0 = n // 2
	bgap = b - b0
	mink = min(agap, -bgap)
	maxk = n - mink + 1
	ans = []
	for k in range(mink, maxk, 2):
		ans.append(k)
		if n % 2:
			if k + 1 < maxk:
				ans.append(k + 1)
		elif k + 2 < maxk:
			ans.append(k + 2)
	ans = sorted(set(ans))
	return str(len(ans)) + '\n' + join_str(ans)
maxcc = 1
maxcc = int(input().strip())
for cc in range(maxcc):
	print(do_thing())


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ma = max(n, m)
	mi = min(n, m)
	s = n + m
	s1 = (s + 1) // 2
	s2 = s // 2
	s3 = ma - s1
	a = [s3]
	for i in range(1, s2 - s3 + 1, 1):
		a.append(s3 + 2 * i)
	s3 = ma - s2
	a.append(s3)
	for i in range(1, int(s1 - s3 + 1), 1):
		a.append(s3 + 2 * i)
	a = list(set(a))
	a.sort()
	print(len(a))
	[print(i, end=' ') for i in a]
	print()


def solve(a, b):
	mina = min(a, b)
	maxb = max(a, b)
	n = a + b
	min_sol = (maxb - mina) // 2
	max_sol = n - min_sol
	if (a + b) % 2 == 0:
		return [str(x) for x in list(range(min_sol, max_sol + 1, 2))]
	else:
		return [str(x) for x in range(min_sol, max_sol + 1, 1)]
import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input().decode().strip())
for t in range(T):
	(a, b) = [int(x) for x in input().decode().strip().split(' ')]
	res = solve(a, b)
	print(len(res))
	print(' '.join(res))


t = int(input())
for j in range(t):
	(a, b) = map(int, input().split())
	n = a + b
	if a == 0 or b == 0:
		if (a + b) % 2 != 0:
			print(2)
			print(max(a, b) // 2, max(a, b) // 2 + 1)
			continue
		else:
			print(1)
			print(int((a + b) / 2))
			continue
	elif a != b:
		k1 = 2 * min(a, b) + 1
		k2 = 2 * min(a, b)
		break_least = (n - k1 - 1) // 2 + 1
		if (n - k1 - 1) // 2 + 1 == (n - k2 - 1) // 2 + 1:
			break_highest = break_least
		else:
			break_highest = break_least + 1
		count = 0
		while count < min(a, b):
			break_highest = break_highest + 2
			count = count + 1
		if (n - k1 - 1) // 2 + 1 == (n - k2 - 1) // 2 + 1:
			num = (break_highest - break_least) // 2 + 1
		else:
			num = break_highest - break_least + 1
		print(int(num))
		i = break_least
		while i <= break_highest:
			print(int(i), end=' ')
			if (n - k1 - 1) // 2 + 1 == (n - k2 - 1) // 2 + 1:
				i = i + 2
			else:
				i = i + 1
	if a == b:
		print(int(a + 1))
		i = 0
		while i <= n:
			print(int(i), end=' ')
			i = i + 2


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from bisect import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 8
	n = random.randint(2, N)
	n = 6
	a = [(random.randint(1, 9), random.randint(1, 9)) for i in range(n)]
	return a

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(inp)
		a2 = solve(inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]
show_flg = False
show_flg = True
ans = 0

def solve(a, b):
	n = a + b
	rt = set()
	(x, y) = (-~n // 2, n // 2)
	for k in range(n + 1):
		s = x - a
		t = y - b
		if s + t != 0:
			continue
		if 0 <= k + s <= 2 * x and 0 <= k - s <= 2 * y and ((k + s) % 2 == 0) and ((k - s) % 2 == 0):
			rt.add(k)
	(y, x) = (-~n // 2, n // 2)
	for k in range(n + 1):
		s = x - a
		t = y - b
		if s + t != 0:
			continue
		if 0 <= k + s <= 2 * x and 0 <= k - s <= 2 * y and ((k + s) % 2 == 0) and ((k - s) % 2 == 0):
			rt.add(k)
	return sorted(rt)
for _ in range(I()):
	ans = 0
	(a, b) = LI()
	ans = solve(a, b)
	print(len(ans))
	print(*ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	n = a + b
	if n % 2 == 0:
		m = n // 2
		x = m - a
		y = n - x
		z = (y - x) // 2 + 1
		print(z)
		print(' '.join(map(str, range(x, y + 1, 2))))
	else:
		m = n // 2
		x = m - a
		y = n - x
		z = y - x + 1
		print(z)
		print(' '.join(map(str, range(x, y + 1))))


for t in range(int(input())):
	(a, b) = map(int, input().split())
	l = abs(a - b) // 2
	r = a + b - l
	x = 1
	if (a + b) % 2 == 0:
		x = 2
	ans = list(range(l, r + 1, x))
	print(len(ans))
	print(' '.join(map(str, ans)))


import sys as _sys

def _main():
	[tests_n] = _read_ints()
	for i_test in range(tests_n):
		[a, b] = _read_ints()
		result = find_all_possible_total_breaks_numbers(a, b)
		print(len(result))
		print(*sorted(result))

def find_all_possible_total_breaks_numbers(a_wins_n, b_wins_n):
	result = set()
	result.update(_find_all_possible_total_breaks_numbers_with_fixed_order(a_wins_n, b_wins_n))
	result.update(_find_all_possible_total_breaks_numbers_with_fixed_order(b_wins_n, a_wins_n))
	return result

def _find_all_possible_total_breaks_numbers_with_fixed_order(first_wins_n, second_wins_n):
	total_games_n = first_wins_n + second_wins_n
	first_serving_n = len(range(0, total_games_n, 2))
	second_serving_n = len(range(1, total_games_n, 2))
	if first_wins_n <= first_serving_n:
		second_breaks_n = first_serving_n - first_wins_n
		first_breaks_n = 0
	else:
		first_breaks_n = first_wins_n - first_serving_n
		second_breaks_n = 0
	while first_breaks_n <= second_serving_n and second_breaks_n <= first_serving_n:
		yield (first_breaks_n + second_breaks_n)
		first_breaks_n += 1
		second_breaks_n += 1

def _read_ints():
	return map(int, _sys.stdin.readline().split())
_main()


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if (a + b) % 2 == 0:
		d = abs(a - b) // 2
		m = (a + b) // 2 - d
		print(m + 1)
		for borys_break in range(m + 1):
			print(2 * borys_break + d, end=' ')
		print()
	else:
		ans = set()
		big_half = (a + b + 1) // 2
		for bb in range(big_half + 1):
			ba = a - (big_half - bb)
			if 0 <= ba < big_half:
				ans.add(bb + ba)
		for bb in range(big_half):
			ba = a - (big_half - 1 - bb)
			if 0 <= ba <= big_half:
				ans.add(bb + ba)
		print(len(ans))
		for possible in sorted(ans):
			print(possible, end=' ')
		print()


class Solver:

	def __init__(self):
		self._ans = []
		tc = int(input())
		for _ in range(tc):
			(a, b) = map(int, input().strip().split())
			ans = set()
			self._solve(a, b, (a + b + 1) // 2, (a + b) // 2, ans)
			self._solve(b, a, (a + b + 1) // 2, (a + b) // 2, ans)
			self._ans.append(sorted(ans))
		[print(len(ans), '\n', ' '.join((str(_) for _ in ans))) for ans in self._ans]

	def _solve(self, a, b, p, q, ans: set):
		for x in range(p + 1):
			y = a - (p - x)
			if 0 <= y <= q:
				ans.add(x + y)
Solver()


from math import ceil
for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	avg = (a + b) // 2
	start = avg - min(a, b)
	end = min(ceil((a + b) / 2), a) + min(ceil((a + b) / 2), b)
	if (a + b) % 2 == 0:
		start = (max(a, b) - min(a, b)) // 2
		end = start + min(a, b) * 2
		print((end - start) // 2 + 1)
		k = []
		for i in range(start, end + 1, 2):
			k.append(i)
		print(*k)
	else:
		print(end - start + 1)
		k = []
		for i in range(start, end + 1):
			k.append(i)
		print(*k)


t = int(input().strip())

def breaks(serves, won):
	bs = []
	for i in range(won + 1):
		bs.append(serves - i + (won - i))
	return bs
for _ in range(t):
	(a, b) = list(map(int, input().strip().split()))
	games = a + b
	mini = min(a, b)
	bs = []
	half = games // 2
	bs.extend(breaks(half, mini))
	if games % 2 == 1:
		half += 1
		bs.extend(breaks(half, mini))
	bs.sort()
	print(len(bs))
	print(*bs)


import math

def solve(m, n):
	res = []
	for mb in range(0, m + 1):
		floor_res = math.floor((m + n) / 2)
		if floor_res - mb >= 0 and n - floor_res + mb >= 0:
			res.append(2 * mb + n - floor_res)
	return res
for i in range(int(input())):
	[m, n] = list(map(int, input().split()))
	res1 = solve(m, n)
	res2 = solve(n, m)
	res = sorted(res1 + res2)
	res = set(res)
	res = list(map(str, res))
	print(len(res))
	print(' '.join(res))


t = int(input())
for u in range(t):
	(a, b) = map(int, input().split())
	ans = []
	n = a + b
	for i in range(a + b + 1):
		f = 0
		qa = n // 2 + n % 2
		qb = n // 2
		if (qb + i - b) % 2 == 0 and (qa + i - a) % 2 == 0 and ((qb + i - b) // 2 <= a) and ((qa + i - a) // 2 <= b) and ((qb + i - b) // 2 + (qa + i - a) // 2 == i) and ((qb + i - b) // 2 >= 0) and ((qa + i - a) // 2 >= 0):
			f = 1
		qa = n // 2
		qb = n // 2 + n % 2
		if (qb + i - b) % 2 == 0 and (qa + i - a) % 2 == 0 and ((qb + i - b) // 2 <= a) and ((qa + i - a) // 2 <= b) and ((qb + i - b) // 2 + (qa + i - a) // 2 == i) and ((qb + i - b) // 2 >= 0) and ((qa + i - a) // 2 >= 0):
			f = 1
		if f == 1:
			ans.append(i)
	print(len(ans))
	print(*ans)


t = int(input())
for task in range(t):
	(a, b) = list(map(int, input().split()))
	if a < b:
		(a, b) = (b, a)
	n = a + b
	nb = n // 2
	minBr = nb - b
	maxBr = n - minBr
	step = 2 - n % 2
	print((-minBr + maxBr) // step + 1)
	for i in range(minBr, maxBr + 1, step):
		print(i, end=' ')
	print()


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
from math import ceil
for _ in range(rn()):
	(a, b) = rns()
	n = a + b
	ans = set()

	def f(ans, c, d):
		mi = abs(a - c)
		ma = min(a, d) + min(b, c)
		for i in range(mi, ma + 1, 2):
			ans.add(i)
	f(ans, n // 2, ceil(n / 2))
	f(ans, ceil(n / 2), n // 2)
	ans = sorted(list(ans))
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = a + b
	s = set()
	for k in range(a + b + 1):
		for i in range(2):
			if i == 0:
				(a_, b_) = (l // 2, l - l // 2)
			else:
				(b_, a_) = (l // 2, l - l // 2)
			x = l - (l - k + b_ + b) // 2
			y = a_ - x
			w = b - y
			z = b_ - w
			if x + y == a_ and z + w == b_ and (x + z == a) and (y + w == b) and (x + w == k) and (y + z == l - k) and (x + y + w + z == l) and (x >= 0) and (y >= 0) and (z >= 0) and (w >= 0):
				s.add(k)
	print(len(s))
	print(*sorted(s))


import sys
import math
from collections import Counter
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	n = a + b
	ans = []
	if n % 2 == 0:
		for y in range(0, n // 2 + 1):
			x = y + a - n // 2
			if x >= 0 and x <= n // 2 and (x + y <= n):
				ans.append(x + y)
	else:
		for y in range(0, (n + 1) // 2 + 1):
			x = y + a - (n + 1) // 2
			if x >= 0 and x <= (n - 1) // 2 and (x + y <= n):
				ans.append(x + y)
		for y in range(0, (n - 1) // 2 + 1):
			x = y + a - (n - 1) // 2
			if x >= 0 and x <= (n + 1) // 2 and (x + y <= n):
				ans.append(x + y)
	ans = sorted(list(set(ans)))
	print(len(ans))
	if len(ans) > 0:
		print(' '.join((str(i) for i in ans)))


for i in range(int(input())):
	x = input()
	x = list(x.split())
	a = int(x[0])
	b = int(x[1])
	f = set([])
	t = a + b
	if t % 2 == 0:
		for y in range(0, b + 1):
			x = t / 2 - y
			c = b - y
			d = a - x
			if x >= 0 and c >= 0 and (d >= 0):
				if y + d not in f:
					f.add(int(y + d))
	else:
		for y in range(0, b + 2):
			x = t / 2 - y - 0.5
			c = b - y
			d = a - x
			x1 = t / 2 - y + 0.5
			c1 = b - y
			d1 = a - x1
			if x >= 0 and c >= 0 and (d >= 0):
				if y + d not in f:
					f.add(int(y + d))
			if x1 >= 0 and c1 >= 0 and (d1 >= 0):
				if y + d1 not in f:
					f.add(int(y + d1))
	print(len(f))
	f = sorted(f)
	for i in f:
		print(i, end=' ')
	print()


from math import ceil, floor
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	breaks = set()
	p = ceil((a + b) / 2)
	q = floor((a + b) / 2)
	for x_i in range(p + 1):
		y = a - p + x_i
		if -1 < y <= q:
			breaks.add(x_i + y)
	p = floor((a + b) / 2)
	q = ceil((a + b) / 2)
	for y_i in range(q + 1):
		x = b - q + y_i
		if -1 < x <= p:
			breaks.add(x + y_i)
	print(len(breaks))
	print(*sorted(breaks))


import os, sys
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def funodd(n, a, b):
	if a > b:
		(a, b) = (b, a)
	minn = n // 2 - a
	maxx = n // 2 + 1 + a
	l = []
	for i in range(minn, maxx + 1):
		l.append(i)
	return l

def aa(a, b):
	return (min(a, b), max(a, b))
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	n = a + b
	if n % 2 == 0:
		(a, b) = aa(a, b)
		ans = []
		for i in range(n // 2 - a, n // 2 + a + 1, 2):
			ans.append(i)
		print(len(ans))
		print(*ans)
	else:
		ans = funodd(n, a, b)
		print(len(ans))
		print(*ans)


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: math.gcd(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(11)]
prime[0] = prime[1] = False

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				prime[i] = False
		p += 1

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
t = 1
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())

	def count(a, b):
		n = a + b
		shareA = (n + 1) // 2
		shareB = n // 2
		res = set()
		for i in range(min(shareA, a) + 1):
			ownA = i
			otherA = a - i
			if otherA > shareB:
				continue
			ownB = shareB - otherA
			otherB = b - ownB
			res.add(otherA + otherB)
		return res
	s1 = count(a, b)
	s2 = count(b, a)
	s = list(s1) + list(s2)
	s = list(set(s))
	s.sort()
	print(len(s))
	print(*s)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 2:
		mi = (a + b) // 2 - min(a, b)
		ma = a + b - mi
		n = ma - mi + 1
		print(n)
		print(*list(range(mi, ma + 1)))
	else:
		mi = (a + b) // 2 - min(a, b)
		ma = a + b - mi
		n = (ma - mi) // 2 + 1
		print(n)
		print(*list(range(mi, ma + 1, 2)))


def main():
	import sys
	input = sys.stdin.buffer.readline
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		tmp = a + b
		s = []
		m = min(a, b)
		ans = 0
		for i in range(a + b):
			if i % 2 == 0:
				if a > 0:
					s.append(0)
					a -= 1
					ans += 1
				else:
					s.append(1)
					b -= 1
			elif b > 0:
				s.append(1)
				b -= 1
				ans += 1
			else:
				s.append(0)
				a -= 1
		res = set([ans])
		for i in range(m):
			if ans - 2 * (i + 1) >= 0:
				res.add(ans - 2 * (i + 1))
		res2 = list(res)
		for i in res2:
			if tmp - i >= 0:
				res.add(tmp - i)
		print(len(res))
		print(*sorted(list(set(res))))
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	n = a + b
	br = []
	if n % 2 == 0:
		c_1 = n // 2
		a_0 = 0
		a_1 = 0
		b_0 = 0
		b_1 = 0
		for i in range(0, c_1 + 1):
			a_1 = i
			a_0 = a - i
			b_1 = c_1 - i
			b_0 = b - b_1
			if a_1 >= 0 and a_0 >= 0 and (b_1 >= 0) and (b_0 >= 0):
				br.append(a_1 + b_0)
	else:
		c_1 = n // 2
		a_0 = 0
		a_1 = 0
		b_0 = 0
		b_1 = 0
		for i in range(0, c_1 + 1):
			a_1 = i
			a_0 = a - i
			b_1 = c_1 - i
			b_0 = b - b_1
			if a_1 >= 0 and a_0 >= 0 and (b_1 >= 0) and (b_0 >= 0):
				br.append(a_1 + b_0)
		c_1 = n // 2 + 1
		a_0 = 0
		a_1 = 0
		b_0 = 0
		b_1 = 0
		for i in range(0, c_1 + 1):
			a_1 = i
			a_0 = a - i
			b_1 = c_1 - i
			b_0 = b - b_1
			if a_1 >= 0 and a_0 >= 0 and (b_1 >= 0) and (b_0 >= 0):
				br.append(a_1 + b_0)
	br = list(set(br))
	br.sort()
	print(len(br))
	print(*br)


import sys
import math
import heapq
from collections import defaultdict as dd
from collections import OrderedDict as od
from collections import deque
from itertools import permutations as pp
from itertools import combinations as cc
from sys import stdin
from functools import cmp_to_key
from functools import lru_cache
from bisect import bisect_left as bs_l
from bisect import bisect_right as bs_r
input = sys.stdin.readline
mod = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)
T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	arr = []
	if (a + b) % 2 == 0:
		k = (a + b) // 2
		(mn, mx) = (10 ** 9, -1)
		if a >= k:
			mn = a - k
		else:
			mn = b - k
		mx = min(a, k) + min(b, k)
		for i in range(mn, mx + 1, 2):
			arr.append(i)
		print(len(arr))
		print(*arr)
	else:
		k = (a + b + 1) // 2
		(mn, mx) = (10 ** 9, -1)
		if a >= k:
			mn = a - k
		else:
			mn = b - k
		mx = min(a, k) + min(b, k)
		for i in range(mn, mx + 1):
			arr.append(i)
		print(len(arr))
		print(*arr)


def solve(a, b):
	(a, b) = (min(a, b), max(a, b))
	n = a + b
	res = set()
	for i in range(0, a + 1):
		b1 = n // 2 - i + a - i
		res.add(b1)
	for i in range(0, a + 1):
		b1 = n - n // 2 - i + a - i
		res.add(b1)
	return sorted(list(res))
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	r = solve(a, b)
	print(len(r))
	print(*r)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	size = arr[0] + arr[1]
	max_num_ind = -1
	if arr[0] > arr[1]:
		max_num_ind = 0
	else:
		max_num_ind = 1
	ans_arr = []
	if size % 2 == 0:
		a = size // 2
		b = a
		min_ans = abs(arr[0] - a)
		max_ans = min(arr) + a
		for num in range(min_ans, max_ans + 1, 2):
			ans_arr.append(num)
	else:
		a = size // 2 + 1
		b = a - 1
		arr_debutes = [a, b]
		arr_debutes_1 = [b, a]
		min_ans = abs(arr[0] - a)
		min_ans_1 = abs(arr[0] - b)
		max_ans = min(arr) + arr_debutes[(max_num_ind + 1) % 2]
		max_ans_1 = min(arr) + arr_debutes_1[(max_num_ind + 1) % 2]
		for num in range(min_ans, max_ans + 1, 2):
			ans_arr.append(num)
		for num in range(min_ans_1, max_ans_1 + 1, 2):
			ans_arr.append(num)
	print(len(ans_arr))
	print(*sorted(ans_arr))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	res = []
	if (a + b) % 2 == 0:
		minval = (a + b) // 2 - min(a, b)
		maxval = (a + b) // 2 + min(a, b)
		for i in range(minval, maxval + 1):
			if i % 2 == minval % 2:
				res.append(str(i))
	if (a + b) % 2 == 1:
		minval = (a + b) // 2 - min(a, b)
		maxval = (a + b) // 2 + min(a, b) + 1
		for i in range(minval, maxval + 1):
			res.append(str(i))
	print(len(res))
	print(' '.join(res))


exec('\ndef my_solver_bitch(prakhar_shukla, sudheer_ranjan):\n    prakhar_shukla, sudheer_ranjan = min(prakhar_shukla, sudheer_ranjan), max(prakhar_shukla, sudheer_ranjan)\n    n = prakhar_shukla + sudheer_ranjan\n    res = set()\n    for i in range(0, prakhar_shukla + 1):\n        b1 = n // 2 - i + prakhar_shukla - i\n        res.add(b1)\n    for i in range(0, prakhar_shukla + 1):\n        b1 = n - n // 2 - i + prakhar_shukla - i\n        res.add(b1)\n    return res\n\n\nfor _ in range(int(input())):\n    a, b = map(int, input().split())\n    r = list(my_solver_bitch(a, b))\n    r.sort()\n    print(len(r))\n    print(*r)\n')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	tot = a + b
	pos1 = tot // 2
	pos2 = tot // 2
	if tot % 2 != 0:
		pos2 += 1
	ans = []
	upper1 = min(pos1, b) + min(pos2, a)
	lower1 = 0
	if pos1 <= a:
		lower1 += a - pos1
	if pos2 <= b:
		lower1 += b - pos2
	upper2 = min(pos2, b) + min(pos1, a)
	lower2 = 0
	if pos2 <= a:
		lower2 += a - pos2
	if pos1 <= b:
		lower2 += b - pos1
	for i in range(0, tot + 1):
		inc = -1
		if i >= lower1 and i <= upper1:
			if lower1 % 2 == 0 and i % 2 == 0:
				inc = i
			elif lower1 % 2 != 0 and i % 2 != 0:
				inc = i
		if i >= lower2 and i <= upper2:
			if lower2 % 2 == 0 and i % 2 == 0:
				inc = i
			elif lower2 % 2 != 0 and i % 2 != 0:
				inc = i
		if inc != -1:
			ans.append(inc)
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print('')


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	for _ in range(1, ii() + 1):
		(a, b) = mi()
		d = abs(a - b) // 2
		if a + b & 1:
			print(a + b - 2 * d + 1)
			for i in range(d, a + b - d + 1):
				print(i, end=' ')
		else:
			print((a + b - 2 * d) // 2 + 1)
			for i in range(d, a + b - d + 1, 2):
				print(i, end=' ')
		print()
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


for s in [*open(0)][1:]:
	(a, b) = sorted(map(int, s.split()))
	s = a + b + 1
	r = [2 * i + b + j - s // 2 for i in range(a + 1) for j in range(2 - s % 2)]
	print(len(r), *r)


ttt_ = int(input())
for __t in range(ttt_):
	(a, b) = map(int, input().split())
	ab = a + b
	k = 0
	if a < b:
		t = a
		a = b
		b = t
	if a == b:
		for d in range(0, ab + 1, 2):
			k += 1
		print(k)
		for d in range(0, ab + 1, 2):
			print(d, end=' ')
		print()
	elif b == 0:
		if a % 2 == 1:
			print(2)
			print(a // 2, a // 2 + 1)
		else:
			print(1)
			print(a // 2)
	else:
		if ab % 2 == 1:
			for d in range(a - (ab + 1) // 2, b + (ab + 1) // 2 + 1):
				k += 1
			print(k)
			for d in range(a - (ab + 1) // 2, b + (ab + 1) // 2 + 1):
				print(d, end=' ')
		else:
			for d in range(a - ab // 2, b + ab // 2 + 1, 2):
				k += 1
			print(k)
			for d in range(a - ab // 2, b + ab // 2 + 1, 2):
				print(d, end=' ')
		print()


import sys
from math import *
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	c = abs(a - b)
	ans = []
	if c % 4 == 0:
		j = c // 4 * 2
		for i in range(a + 1):
			ans.append(j)
			j += 2
	if c % 4 == 2:
		j = (c - 2) // 4 * 2 + 1
		for i in range(a + 1):
			ans.append(j)
			j += 2
	if c % 4 == 3:
		j = (c - 3) // 4 * 2 + 1
		for i in range((a + 1) * 2):
			ans.append(j)
			j += 1
	if c % 4 == 1:
		j = (c - 1) // 4 * 2
		for i in range((a + 1) * 2):
			ans.append(j)
			j += 1
	print(len(ans))
	print(*ans)


from itertools import combinations, permutations
from sys import path_hooks, stdin, stdout
from collections import Counter, deque
import math
from copy import deepcopy
import random
import heapq
import sys
sys.setrecursionlimit(10 ** 5)

def mapinput():
	return map(int, stdin.readline().split())

def strinput():
	return stdin.readline().strip()

def listinput():
	return list(map(int, stdin.readline().split()))

def intinput():
	return int(stdin.readline().strip())

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	ans = []
	for p in range(n + 1):
		if prime[p]:
			ans.append(p)
	return ans
coprime1 = {6: 100003, 5: 10007, 4: 1009, 3: 101, 2: 11, 1: 2, 7: 1000003, 8: 10000019, 9: 100000007}
coprime2 = {8: 10000169, 9: 100000049, 7: 1000033, 6: 100019, 5: 10009, 4: 1013, 3: 103, 2: 13, 1: 3}

def writ(ss):
	stdout.write(str(ss) + '\n')
mod = 998244353

def sumn(n):
	return n * (n + 1) // 2

def perm(lis):
	if len(lis) < 2:
		return lis
	anss = []
	for i in range(len(lis)):
		ele = lis[i]
		liss = lis[:i] + lis[i + 1:]
		for j in perm(liss):
			anss.append(ele + j)
	return anss
for test in range(intinput()):

	def solve():
		(a, b) = mapinput()
		if a + b & 1 == 0:
			n = a + b >> 1
			aa = abs((n & 1) - (a & 1))
			ans = deque([i for i in range(aa, a + b + 1, 2)])
			diff = abs(a - b) >> 2
			for i in range(diff):
				ans.popleft()
				ans.pop()
		else:
			ans = deque([i for i in range(a + b + 1)])
			diff = abs(a - b) >> 1
			for i in range(diff):
				ans.popleft()
				ans.pop()
		print(len(ans))
		print(*ans)
	solve()


import sys
from random import *
from bisect import *
from itertools import permutations as prm, product
from heapq import *
from math import gcd, sqrt, ceil, floor
from functools import *
from copy import *
pl = 1
sys.setrecursionlimit(10 ** 5)
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('outpt.txt', 'w')

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def ff():
	sys.stdout.flush()

def google(tc, *ans):
	print('Case #' + str(tc) + ':', *ans)

def bits(i, n):
	p = bin(i)[2:]
	return (n - len(p)) * '0' + p
t = fi()
f = t
while t:
	t -= 1
	(a, b) = mi()
	ans = []
	for i in range(a + b + 1):
		al = (a + b + 1) // 2
		bo = (a + b) // 2
		aw = (a + i - al) // 2
		bw = i - (bo + i - b) // 2
		if (bo + i - b) % 2 == 0 and (a + i - al) % 2 == 0 and (0 <= aw <= i) and (0 <= bw <= i) and (aw == i - bw) and (aw <= a) and (bw <= b):
			ans.append(i)
			continue
		al = (a + b) // 2
		bo = (a + b + 1) // 2
		aw = (a + i - al) // 2
		bw = i - (bo + i - b) // 2
		if (bo + i - b) % 2 == 0 and (a + i - al) % 2 == 0 and (0 <= aw <= i) and (0 <= bw <= i) and (aw == i - bw) and (aw <= a) and (bw <= b):
			ans.append(i)
			continue
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = []
	n = a + b
	if (a + b) % 2 == 0:
		a = min(a, b)
		for i in range(n // 2 - a, n // 2 + a + 1, 2):
			l.append(i)
	else:
		a = min(a, b)
		for i in range(n // 2 - a, n // 2 + a + 2):
			l.append(i)
	print(len(l))
	print(*l)


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left
mod = 998244353
mod = 1000000007

def solve(we):
	(a, b) = main()
	(a, b) = (max(a, b), min(a, b))
	t = a - b
	t1 = (t + 1) // 2
	t2 = t // 2
	l = set()
	l.add(2 * b + t1)
	for i in range(t2, b + b + t1 + 1, 2):
		l.add(i)
	z = list(l)
	for i in z:
		l.add(a + b - i)
	print(len(l))
	print(*sorted(l))
qwe = 1
qwe = iin()
for _ in range(qwe):
	solve(_ + 1)


def solve():
	(a, b) = map(int, input().split())
	if a == b:
		print((a + b) // 2 + 1)
		for i in range(0, a + b + 1, 2):
			print(i, end=' ')
		print()
	elif abs(a - b) == 1:
		print(a + b + 1)
		for i in range(a + b + 1):
			print(i, end=' ')
		print()
	elif a == 0 or b == 0:
		if a == 0 and b % 2 == 0:
			print(1)
			print(b // 2)
		elif b == 0 and a % 2 == 0:
			print(1)
			print(a // 2)
		else:
			print(2)
			if a == 0:
				print(b // 2, b // 2 + 1, end=' ')
			else:
				print(a // 2, a // 2 + 1, end=' ')
			print()
	elif (a + b) % 2 == 0:
		x = abs(a - b) // 2
		y = a + b - abs(a - b) // 2
		print((y - x) // 2 + 1)
		for i in range(x, y + 1, 2):
			print(i, end=' ')
		print()
	else:
		print(a + b - abs(a - b) // 2 + 1 - abs(a - b) // 2)
		for i in range(abs(a - b) // 2, a + b - abs(a - b) // 2 + 1):
			print(i, end=' ')
		print()
t = int(input())
while t:
	solve()
	t -= 1


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	mi = min(a, b)
	Ma = max(a, b)
	m = 0
	k = []
	if (mi + Ma) % 2 == 0:
		m = mi + 1
		k = [i for i in range((Ma - mi) // 2, (3 * mi + Ma) // 2 + 1, 2)]
	else:
		m = 2 * (mi + 1)
		k = [i for i in range((Ma - mi - 1) // 2, (3 * mi + Ma + 1) // 2 + 1)]
	print(m)
	for item in k:
		print(item, end=' ')
	print()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	am = (a + b + 1) // 2
	bm = a + b - am
	i = abs(am - a)
	ans = set()
	ans.add(i)
	for j in range(1, min(a, b) + 1):
		i += 2
		ans.add(i)
	bm = (a + b + 1) // 2
	am = a + b - bm
	i = abs(am - a)
	ans.add(i)
	for j in range(1, min(a, b) + 1):
		i += 2
		ans.add(i)
	print(len(ans))
	for i in sorted(ans):
		print(i, end=' ')
	print()


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):
		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)
	elif 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)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	k = []
	if (a + b) % 2 == 0:
		for i in range(a + b + 1):
			if i >= abs(a - b) // 2 and (i - abs(a - b) // 2) % 2 == 0 and ((i - abs(a - b) // 2) // 2 <= min(a, b)) and ((i - abs(a - b) // 2) // 2 + abs(a - b) // 2 <= max(a, b)):
				k.append(i)
	else:
		for i in range(a + b + 1):
			if i >= (abs(a - b) + 1) // 2 and (i - (abs(a - b) + 1) // 2) % 2 == 0 and ((i - (abs(a - b) + 1) // 2) // 2 <= min(a, b)) and ((i - (abs(a - b) + 1) // 2) // 2 + (abs(a - b) + 1) // 2 <= max(a, b)) or (i >= (abs(a - b) - 1) // 2 and (i - (abs(a - b) - 1) // 2) % 2 == 0 and ((i - (abs(a - b) - 1) // 2) // 2 <= min(a, b)) and ((i - (abs(a - b) - 1) // 2) // 2 + (abs(a - b) - 1) // 2 <= max(a, b))):
				k.append(i)
	print(len(k))
	print(*k)


def solve(A, B, C, D):
	output = []
	min_break = C + D - min(A, C) - min(B, D)
	max_break = min(B, C) + min(A, D)
	for i in range(min_break, max_break + 1, 2):
		output.append(i)
	return output
T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 0:
		k_array = solve((a + b) // 2, (a + b) // 2, a, b)
	else:
		opt1 = solve((a + b) // 2 + 1, (a + b) // 2, a, b)
		opt2 = solve((a + b) // 2, (a + b) // 2 + 1, a, b)
		k_array = opt1 + opt2
	k_array.sort()
	print(len(k_array))
	print(' '.join((str(num) for num in k_array)))


T = int(input())

def solve():
	(a, b) = map(int, input().split())
	n = a + b
	if n % 2 == 0:
		c = min(a, b) + 1
		print(c)
		print(*[x for x in range(n // 2 - min(a, b), n // 2 - min(a, b) + 2 * c, 2)])
	else:
		start = n // 2 - min(a, b)
		c = (min(a, b) + 1) * 2
		print(c)
		print(*[x for x in range(start, start + c)])
for _ in range(T):
	solve()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	start = min(abs((a + b) // 2 + (a + b) % 2 - a), abs((a + b) // 2 + (a + b) % 2 - b))
	end = start + min(a, b) * 2 + 1
	if (a + b) % 2 == 0:
		print((end - start) // 2 + 1)
		for i in range(start, end, 2):
			print(i, end=' ')
	if (a + b) % 2 == 1:
		print(end - start + 1)
		for i in range(start, end + 1):
			print(i, end=' ')
	if _ < t - 1:
		print()


from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from math import ceil, floor, log, gcd, sqrt
from collections import Counter, deque
from heapq import heappush, heappop, heapify

def re():
	return stdin.readline().rstrip()

def ints():
	return map(int, stdin.readline().split())

def test(tc):
	for _ in range(tc):
		solve()
mod = 1000000007
nl = '\n'

class Dsu:

	def __init__(self, n):
		self.parent = list(range(n))
		self.rank = [1] * n

	def find(self, x):
		while x != self.parent[x]:
			self.parent[x] = self.parent[self.parent[x]]
			x = self.parent[x]
		return x

	def union(self, x, y):
		(px, py) = (self.find(x), self.find(y))
		if px == py:
			return 0
		if self.rank[py] > self.rank[px]:
			(px, py) = (py, px)
		self.parent[py] = px
		self.rank[px] += self.rank[py]
		return 1

	def get_size(self, x):
		return self.rank[self.find(x)]

class SegTree:

	def __init__(self, n, array):
		self.n = n
		self.tree = [0] * (2 * n)
		for i in range(n, 2 * n):
			self.tree[i] = array[i - n]
		for i in range(n - 1, -1, -1):
			self.tree[i] = self.tree[2 * i] + self.tree[2 * i + 1]

	def update(self, i, val):
		self.tree[i] = val
		while i:
			self.tree[i] = self.tree[i * 2] + self.tree[i * 2 + 1]
			i //= 2

	def query(self):
		pass

	def top(self):
		return self.tree[0]

def solve():
	(a, b) = ints()
	n = a + b
	spots = (n + 1) // 2
	ans = set()
	lo = a - (spots - (n & 1)) if a >= spots else spots - (n & 1) - a
	hi = n - (a - spots) if a > spots else n - (b - (spots - (n & 1)))
	for i in range(lo, hi + 1, 2):
		ans.add(i)
	lo = b - (spots - (n & 1)) if b >= spots else spots - (n & 1) - b
	hi = n - (b - spots) if b > spots else n - (a - (spots - (n & 1)))
	for i in range(lo, hi + 1, 2):
		ans.add(i)
	print(len(ans))
	print(*sorted(ans))
	return
test(int(re()))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	memo = {}
	(lower, upper) = ((a + b) // 2, (a + b + 1) // 2)
	for y in range(b + 1):
		x1 = a + y - upper
		x2 = lower + y - b
		if x1 == x2 and a >= x1 >= 0:
			memo[int(x1 + y)] = True
		x1 = a + y - lower
		x2 = upper + y - b
		if x1 == x2 and a >= x1 >= 0:
			memo[int(x1 + y)] = True
	ans = memo.keys()
	print(len(ans))
	for a in ans:
		print(a, end=' ')
	print()


mm = int(input())
for i in range(mm):
	aa = []
	(a, b) = list(map(int, input().split()))
	n = max(a, b)
	z = (a + b) // 2
	s = a + b
	if (a + b) % 2 == 0:
		for ii in range(z + 1):
			if ii + z >= n:
				aa.append(z - ii + n - ii)
	else:
		for ii in range(z + 1):
			if ii + z + 1 >= n:
				aa.append(z - ii + n - ii)
		z = z + 1
		for ii in range(z + 1):
			if ii + s - z >= n:
				aa.append(z - ii + n - ii)
	aa.sort()
	print(len(aa))
	print(*aa)


t = int(input())

def solve(a, bseat, nseat):
	bsarr = 0
	nsarr = 0
	if a > nseat:
		nsarr = nseat
		bsarr = a - nsarr
	else:
		nsarr = a
	ans.add(bsarr + nseat - nsarr)
	curr = bsarr + nseat - nsarr
	while nsarr and bsarr < bseat:
		bsarr += 1
		nsarr -= 1
		curr += 2
		if curr <= total:
			ans.add(curr)
while t:
	t -= 1
	(a, b) = [int(x) for x in input().split()]
	total = a + b
	bseat = total // 2
	nseat = total - bseat
	ans = set()
	solve(a, bseat, nseat)
	solve(a, nseat, bseat)
	solve(b, bseat, nseat)
	solve(b, nseat, bseat)
	print(len(ans))
	print(*sorted(ans))


import math

def solve():
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	l = math.floor((a - b) / 2)
	r = math.ceil((a + 3 * b) / 2)
	ans = []
	if (a + b) % 2 == 0:
		for i in range(l, r + 1, 2):
			ans.append(i)
	else:
		for i in range(l, r + 1):
			ans.append(i)
	print(len(ans))
	print(*ans)
for _ in range(int(input())):
	solve()


def f(a, b):
	m = 0
	l = []
	if (a + b) % 2 == 0:
		if a == 0 or b == 0:
			m = 1
			l.append((a + b) // 2)
		else:
			var = abs(a - b) // 2
			for i in range(min(a, b) + 1):
				m = m + 1
				l.append(var + 2 * i)
	elif a == 0 or b == 0:
		m = 2
		l.append((a + b) // 2)
		l.append((a + b + 1) // 2)
	else:
		var1 = abs(a - b) // 2
		var2 = var1 + 1
		var = min(a, b)
		m = (var + 1) * 2
		for i in range(m):
			l.append(var1 + i)
	return (m, l)
t = int(input())
i = 0
while i != t:
	i = i + 1
	x = input().split(' ')
	a = int(x[0])
	b = int(x[1])
	(m, l) = f(a, b)
	print(m)
	print(*l)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def ispali(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	for _ in range(ii()):
		(a, b) = mi()
		ttl = a + b
		ans = []
		if ttl % 2:
			(x1, y1) = (ttl // 2, ttl // 2 + 1)
			(x2, y2) = (y1, x1)
			dmax1 = min(x1, b) + min(y1, a)
			dmax2 = min(x2, b) + min(y2, a)
			ans.append(dmax1)
			ans.append(dmax2)
			dmax1 -= 2
			dmax2 -= 2
			for i in range(min(a, b)):
				ans.append(dmax1)
				ans.append(dmax2)
				dmax1 -= 2
				dmax2 -= 2
		else:
			(x, y) = (ttl // 2, ttl // 2)
			dmax = min(x, b) + min(y, a)
			ans.append(dmax)
			dmax -= 2
			for i in range(min(a, b)):
				ans.append(dmax)
				dmax -= 2
		ans.sort()
		print(len(ans))
		print(*ans)
main()


import math

def subsets_gen(num):

	def generator_h(no, s):
		if len(s) == no:
			yield s
		else:
			yield from generator_h(no, s + '0')
			yield from generator_h(no, s + '1')
	yield from generator_h(num, '')

def perms_gen(pole):
	used = [False for i in range(len(pole))]

	def generator_h(l, m):
		if len(m) == len(l):
			yield m
		else:
			for i in range(len(l)):
				if used[i]:
					continue
				else:
					m.append(l[i])
					used[i] = True
					yield from generator_h(l, m)
					m.pop()
					used[i] = False
	yield from generator_h(pole, [])

def fact(n):
	factors = []
	if n % 2 == 0:
		while n % 2 == 0:
			factors.append(2)
			n //= 2
	poc = 3
	while poc * poc <= n:
		while n % poc == 0:
			factors.append(poc)
			n //= poc
		poc += 2
	if n > 1:
		factors.append(n)
	return factors

def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def NcK(n, k):
	if k == 0 or k == n:
		return 1
	return NcK(n - 1, k - 1) + NcK(n - 1, k)
testcases = 1
testcases = int(input())
for _ in range(testcases):
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 1:
		x = max(a, b) - (a + b + 1) // 2
		y = a + b - (max(a, b) - (a + b + 1) // 2)
		print(y - x + 1)
		for i in range(x, y + 1):
			if i == y:
				print(i)
			else:
				print(i, end=' ')
	else:
		x = max(a, b) - (a + b) // 2
		y = a + b - (max(a, b) - (a + b) // 2)
		print(math.ceil((y - x + 1) / 2))
		for i in range(x, y + 1, 2):
			if i == y:
				print(i)
			else:
				print(i, end=' ')


from sys import stdin
input = stdin.readline

def sub_solution(a, b, a_win, b_win):
	ret = set()
	serve_a = a
	serve_b = b
	break_a = 0
	break_b = 0
	while serve_a > a_win:
		serve_a -= 1
		break_b += 1
	while serve_b > b_win:
		serve_b -= 1
		break_a += 1
	all_break = break_a + break_b
	ret.add(all_break)
	C = min(serve_a, serve_b)
	for i in range(1, C + 1):
		ret.add(all_break + i * 2)
	return ret

def solution():
	(a, b) = map(int, input().split())
	n = a + b
	answer = set()
	answer |= sub_solution(n // 2, n - n // 2, a, b)
	answer |= sub_solution(n - n // 2, n // 2, a, b)
	print(len(answer))
	print(*sorted(answer))
T = int(input())
for _ in range(T):
	solution()


import sys
from collections import Counter
import math
import bisect
import heapq
from itertools import combinations
from collections import defaultdict
num_cases = int(sys.stdin.readline().strip())
for case in range(1, num_cases + 1):
	(A, B) = list(map(int, sys.stdin.readline().split()))
	num_contest = A + B
	break_box = []
	if num_contest % 2 == 0:
		num_alpha = int(num_contest / 2)
		num_beta = int(num_contest / 2)
		for i in range(A + 1):
			need_victory = A - i
			a_break = num_alpha - i
			if a_break >= 0 and need_victory <= num_beta:
				break_box.append(a_break + need_victory)
	else:
		num_alpha = int((num_contest - 1) / 2)
		num_beta = int((num_contest - 1) / 2) + 1
		for i in range(A + 1):
			need_victory = A - i
			a_break = num_alpha - i
			if a_break >= 0 and need_victory <= num_beta:
				break_box.append(a_break + need_victory)
		num_beta = int((num_contest - 1) / 2)
		num_alpha = int((num_contest - 1) / 2) + 1
		for i in range(A + 1):
			need_victory = A - i
			a_break = num_alpha - i
			if a_break >= 0 and need_victory <= num_beta:
				break_box.append(a_break + need_victory)
	print(len(break_box))
	print(*sorted(break_box))


from sys import *
import math

def solve_case(t):
	(a, b) = [int(x) for x in stdin.readline().rstrip().split()]
	total = a + b
	min_k = 0
	max_k = 0
	a_ser = math.ceil((a + b) / 2)
	min_k = abs(a_ser - a)
	max_k = min(b, a_ser) + min(total - a_ser, a)
	if total % 2 != 0:
		a_ser = math.floor((a + b) / 2)
		min_k = min(min_k, abs(a_ser - a))
		max_k = max(max_k, min(b, a_ser) + min(total - a_ser, a))
		print(max_k - min_k + 1)
		for k in range(min_k, max_k + 1):
			print(k, end=' ')
	else:
		arr = []
		for k in range(min_k, max_k + 1, 2):
			arr.append(k)
		print(len(arr))
		for k in arr:
			print(k, end=' ')
	print('')

def main():
	T = int(stdin.readline().rstrip())
	for t in range(T):
		solve_case(t)
main()


from math import ceil
t = int(input())
for _ in range(t):
	ans = set()
	(a, b) = map(int, input().split())
	Alice = ceil((a + b) / 2)
	Borys = a + b - Alice
	if a < Alice:
		min_break = Alice - a
		max_break = a + b - (Borys - a)
	elif a == Alice:
		min_break = 0
		if (a + b) % 2 == 0:
			max_break = a + b
		else:
			max_break = a + b - 1
	else:
		min_break = a - Alice
		max_break = a + b - (a - Borys)
	for i in range(min_break, max_break + 1, 2):
		ans.add(i)
		ans.add(a + b - i)
	print(len(ans))
	print(' '.join([str(k) for k in sorted(list(ans))]))


t = int(input())
for i in range(0, t):
	(a, b) = map(int, input().split())
	n = a + b
	max_wins = max(a, b)
	possib = []
	S = set()
	if (a + b) % 2 == 0:
		a_serves = n // 2
		b_serves = n // 2
		if a > b:
			(a, b) = (b, a)
		for j in range(0, a + 1):
			breaks = a + a_serves - 2 * j
			S.add(breaks)
	else:
		a_serves = n // 2
		b_serves = n - n // 2
		if a > b:
			(a, b) = (b, a)
		for j in range(0, a + 1):
			breaks = a + a_serves - 2 * j
			S.add(breaks)
			breaks = a + b_serves - 2 * j
			S.add(breaks)
	print(len(S))
	for e in S:
		possib.append(e)
	possib.sort()
	print(*possib)


def solve():
	(a_mas, b_mas) = map(int, input().split())
	a = a_mas
	b = b_mas
	find = [False] * (a + b + 1)
	t1 = ''
	t2 = ''
	for i in range(a + b):
		if i % 2 == 0:
			t1 += '1'
			t2 += '0'
		else:
			t1 += '0'
			t2 += '1'
	s1 = ''
	for i in range(a + b):
		if t1[i] == '1' and a > 0:
			s1 += '1'
			a -= 1
		elif t1[i] == '0' and b > 0:
			s1 += '0'
			b -= 1
		elif a > 0:
			s1 += '1'
			a -= 1
		else:
			s1 += '0'
			b -= 1
	s2 = ''
	a = a_mas
	b = b_mas
	for i in range(a + b):
		if t2[i] == '1' and a > 0:
			s2 += '1'
			a -= 1
		elif t2[i] == '0' and b > 0:
			s2 += '0'
			b -= 1
		elif a > 0:
			s2 += '1'
			a -= 1
		else:
			s2 += '0'
			b -= 1
	score1 = 0
	score2 = 0
	score3 = 0
	score4 = 0
	a = a_mas
	b = b_mas
	for i in range(a + b):
		if s1[i] != t1[i]:
			score1 += 1
		if s2[i] != t2[i]:
			score2 += 1
		if s1[i] != t2[i]:
			score3 += 1
		if s2[i] != t1[i]:
			score4 += 1
	for i in range(score1, score4 + 1, 2):
		find[i] = True
	for i in range(score2, score3 + 1, 2):
		find[i] = True
	ans = []
	for i in range(a + b + 1):
		if find[i]:
			ans.append(i)
	print(len(ans))
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	fin = a + b
	if fin == 2:
		if a == 1:
			print(2)
			print(0, 2)
		else:
			print(1)
			print(1)
		continue
	if fin % 2 == 1:
		temp = abs(a - b)
		lis = []
		for i in range(fin + 1):
			lis.append(i)
		lis = lis[temp // 2:len(lis) - temp // 2]
	if fin % 2 == 0:
		if fin // 2 % 2 == 1:
			lis = []
			if a % 2 == 0:
				for i in range(fin + 1):
					if i % 2 == 1:
						lis.append(i)
			else:
				for i in range(fin + 1):
					if i % 2 == 0:
						lis.append(i)
			cut = (len(lis) - min([a, b]) - 1) // 2
			lis = lis[cut:len(lis) - cut]
		else:
			lis = []
			if a % 2 == 1:
				for i in range(fin + 1):
					if i % 2 == 1:
						lis.append(i)
			else:
				for i in range(fin + 1):
					if i % 2 == 0:
						lis.append(i)
			cut = (len(lis) - min([a, b]) - 1) // 2
			lis = lis[cut:len(lis) - cut]
	print(len(lis))
	for i in lis:
		print(i, end=' ')
	print()


T = int(input())
for testcase in range(1, T + 1):
	(a, b) = list(map(int, input().split()))
	if (a + b) % 2 == 0:
		half = (a + b) // 2
		mi = min(a, b)
		mib = half - mi
		mab = half + mi
		num = (mab - mib) // 2 + 1
		print(num)
		res = []
		i = mib
		while i <= mab:
			res.append(i)
			i += 2
		print(*res)
	else:
		mi = min(a, b)
		ma = max(a, b)
		less = (a + b) // 2
		more = a + b - less
		mib = less - mi
		mab = more + mi
		num = mab - mib + 1
		print(num)
		res = []
		i = mib
		while i <= mab:
			res.append(i)
			i += 1
		print(*res)


T = int(input())
for t in range(T):
	(a, b) = [int(x) for x in input().split()]
	d = abs(a - b) // 2
	if (a + b) % 2 == 0:
		K = list(range(d, a + b - d + 1, 2))
		print(len(K))
		print(' '.join([str(k) for k in K]))
	else:
		K = list(range(d, a + b - d + 1, 1))
		print(len(K))
		print(' '.join([str(k) for k in K]))


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	mn = min(a, b)
	ans = set()
	for i in range(mn + 1):
		(e, o) = (i, mn - i)
		(l, m) = [(a + b) // 2, (a + b + 1) // 2]
		ans.add(l - e + o)
		ans.add(m - o + e)
	print(len(ans))
	print(*sorted(list(ans)))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l = abs(a - b) // 2
	r = a + b - l
	j = 1
	if (a + b) % 2 == 0:
		j = 2
	a = list(range(l, r + 1, j))
	print(len(a))
	print(*a)


for _ in range(int(input())):
	x = list(map(int, input().split()))
	b = max(x)
	a = min(x)
	start = (b - a) // 2
	end = a + b - start
	ans = []
	if a + b & 1:
		for i in range(start, end + 1):
			ans += [i]
		print(len(ans))
		print(*ans)
	else:
		for i in range(start, end + 1, 2):
			ans += [i]
		print(len(ans))
		print(*ans)


t = int(input())
for _ in range(t):
	inp = input().split()
	(a, b) = (int(inp[0]), int(inp[1]))
	n = a + b
	breaks = abs(a - b) // 2
	loser = min(a, b)
	(res, count) = ([], 0)
	while loser + 1:
		res.append(breaks)
		count += 1
		if n % 2:
			res.append(breaks + 1)
			count += 1
		breaks += 2
		loser -= 1
	print(count)
	for num in res:
		print(num, end=' ')
	print()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0:
		if b % 2:
			print(2)
			print(b // 2, b // 2 + 1)
		else:
			print(1)
			print(b // 2)
	elif b == 0:
		if a % 2:
			print(2)
			print(a // 2, a // 2 + 1)
		else:
			print(1)
			print(a // 2)
	else:
		d = abs(a - b) // 2
		ans = []
		if (a + b) % 2:
			value = d
			while value <= a + b - d:
				ans.append(value)
				value += 1
		else:
			value = d
			while value <= a + b - d:
				ans.append(value)
				value += 2
		print(len(ans))
		print(*ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	Min = max(a, b) - (a + b + 1) // 2
	Max = (a + b + 1) // 2 + min(a, b)
	if (a + b) % 2 == 0:
		sp = []
		for i in range(Min, Max + 1, 2):
			sp.append(i)
		print(len(sp))
		print(*sp)
	else:
		sp = []
		for i in range(Min, Max + 1):
			sp.append(i)
		print(len(sp))
		print(*sp)


import math

def solve(a, b):
	ans = set()
	(mi, ma) = (min(a, b), max(a, b))
	min_a = math.floor((ma - mi) / 2)
	max_a = min_a + 2 * mi
	for i in range(min_a, max_a + 2, 2):
		ans.add(i)
	min_a = math.ceil((ma - mi) / 2)
	max_a = min_a + 2 * mi
	for i in range(min_a, max_a + 2, 2):
		ans.add(i)
	ans = sorted(list(ans))
	return (len(ans), ans)

def main():
	ans = []
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split(' '))
		ans.append(solve(a, b))
	for (n, l) in ans:
		print(n)
		print(' '.join(map(str, l)))
main()


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	minn = abs(a - b) // 2
	mux = 0
	if max(a, b) > math.ceil((a + b) / 2):
		mux = math.ceil((a + b) / 2) + min(a, b)
	else:
		mux = a + b
	ans = []
	if (a + b) % 2:
		ans = [i for i in range(minn, mux + 1)]
	else:
		ans = [i for i in range(minn, mux + 1, 2)]
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	f = (a + b) % 2 == 1
	response = []
	for i in range(min(a, b) + 1):
		breaks = (a + b) // 2 - i + min(a, b) - i
		response += [breaks]
		if f:
			response += [breaks + 1]
	print(len(set(response)))
	print(*sorted(list(set(response))))


def main():
	(A, B) = map(int, input().split())
	if A > B:
		(A, B) = (B, A)
	if (A + B) % 2 == 0:
		C = (A + B) // 2
		Ans = [i for i in range(C - A, C - A + 2 * (A + 1), 2)]
	else:
		C = (A + B) // 2
		Ans = [i for i in range(C - A, C - A + 2 * (A + 1), 2)]
		C = (A + B) // 2 + 1
		Ans += [i for i in range(C - A, C - A + 2 * (A + 1), 2)]
	Ans.sort()
	print(len(Ans))
	print(*Ans)
T = int(input())
for _ in range(T):
	main()


import math, io, os, sys
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	r = set()
	c = 0
	if a == b:
		q = list(range(0, a * 2 + 1, 2))
		print(len(q))
		print(*q)
		continue
	d = (max(a, b) - min(a, b)) // 2
	z = 1
	if (max(a, b) - min(a, b)) % 2 == 0:
		z = 2
	r = list(range(d, sum((a, b)) + 1 - d, z))
	print(len(r))
	print(*r)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	n = a + b
	if b < a:
		(a, b) = (b, a)
	d = b - a
	if d % 2 == 0:
		ans = list(range(d // 2, n - d // 2 + 1, 2))
		print(len(ans))
		print(*ans)
	else:
		ans = list(range((d - 1) // 2, n - (d - 1) // 2 + 1))
		print(len(ans))
		print(*ans)


int_inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mul = lambda : map(int, input().split())
mulf = lambda : map(float, input().split())
seq = lambda : list(map(int, input().split()))
import math
from collections import Counter, defaultdict
for _ in range(int_inp()):
	(a, b) = mul()
	c = math.ceil((a + b) / 2)
	d = math.floor((a + b) / 2)
	k = []
	for i in range(a + 1):
		if a - i <= d and i <= c:
			k.append(c + a - 2 * i)
	for i in range(a + 1):
		if a - i <= c and i <= d:
			k.append(d + a - 2 * i)
	k = list(set(k))
	k.sort()
	print(len(k))
	print(*k)


import math
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	N = A + B
	if A < B:
		(A, B) = (B, A)
	a = A - math.ceil(N / 2)
	b = math.floor(N / 2) + B
	if N % 2:
		dat = [i for i in range(a, max(a, b) + 2)]
		print(len(dat))
		print(' '.join((str(i) for i in dat)))
	else:
		dat = [i for i in range(a, max(a, b) + 1, 2)]
		print(len(dat))
		print(' '.join((str(i) for i in dat)))


t = int(input())
for _ in range(t):
	(a, b) = [int(s) for s in input().split()]
	c = (max(a, b) - min(a, b)) // 2
	if (a + b) % 2 == 0:
		res = [i for i in range(c, a + b - c + 1, 2)]
	else:
		res = [i for i in range(c, a + b - c + 1)]
	print(len(res))
	print(' '.join((str(s) for s in res)))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

def so():
	return int(input())

def st():
	return input()

def mj():
	return map(int, input().strip().split(' '))

def msj():
	return map(str, input().strip().split(' '))

def le():
	return list(map(int, input().split()))

def lebe():
	return list(map(int, input()))

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()

def joro(L):
	return ''.join(map(str, L))

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def tr(n):
	return n * (n + 1) // 2

def fb(k, L):
	if k == L[k]:
		return k
	if L[k] == fb(L[k], L):
		return L[k]

def usa(a, b, Y, Z):
	a = fb(a, Y)
	b = fb(b, Y)
	if a != b:
		if Z[a] < Z[b]:
			(a, b) = (b, a)
		Y[b] = a
		Z[a] += Z[b]

def iu():
	import sys
	input = sys.stdin.buffer.readline
	import math as my
	(p, q) = mj()
	c = (p + q) // 2
	d = p + q - c
	L = []
	for i in range(q + 1):
		if p - c + i <= p and p - c + i >= 0:
			L.append(p - c + i * 2)
	(c, d) = (d, c)
	for i in range(q + 1):
		if p - c + i <= p and p - c + i >= 0:
			L.append(p - c + i * 2)
	print(len(set(L)))
	op = list(set(L))
	op.sort()
	print(*op)

def main():
	for i in range(so()):
		iu()
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for q in range(t):
	(a, b) = [int(i) for i in input().split()]
	s = set()
	n = a + b
	n2 = n // 2
	n3 = n - n2
	for i in range(min(n2, a) + 1):
		j = n3 - (a - i)
		if j < 0 or j > b:
			continue
		s.add(i + j)
	(n2, n3) = (n3, n2)
	for i in range(min(n2, a) + 1):
		j = n3 - (a - i)
		if j < 0 or j > b:
			continue
		s.add(i + j)
	s = sorted(list(s))
	print(len(s))
	for i in s:
		print(i, end=' ')
	print()


tt = int(input())

def get(a, b, A, B, u):
	if a - u > B or u > A:
		return -1
	return a - u + A - u
for _ in range(tt):
	(a, b) = map(int, input().split())
	tot = a + b
	A = tot // 2
	B = tot - A
	ans = set()
	for i in range(a + 1):
		t = get(a, b, A, B, i)
		if t != -1:
			ans.add(t)
	A = (tot + 1) // 2
	B = tot - A
	for i in range(a + 1):
		t = get(a, b, A, B, i)
		if t != -1:
			ans.add(t)
	print(len(ans))
	for u in sorted(ans):
		print(u, end=' ')
	print('')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	even = (a + b) // 2 + (a + b) % 2
	odd = (a + b) // 2
	arr = []
	if a < b:
		(a, b) = (b, a)
	if a == 0:
		arr.extend([b - even, a + even])
		arr = list(set(arr))
		arr.sort()
		print(len(arr))
		for i in arr:
			print(i, end=' ')
		print('\n', end='')
		continue
	else:
		for j in range(min(even, b) + 1):
			if b + even - 2 * j >= 0 and a - even + 2 * j >= 0:
				arr.extend([b + even - 2 * j, a - even + 2 * j])
		arr = list(set(arr))
		arr.sort()
		print(len(arr))
		for i in arr:
			print(i, end=' ')
		print('\n', end='')


import sys

def process(a, b):
	n = a + b
	if n % 2 == 0:
		answer = []
		for a1 in range(max(0, n // 2 - b), min(a, n // 2) + 1):
			answer.append(2 * a1 + b - n // 2)
		return answer
	if n % 2 == 1:
		answer = []
		for a1 in range(max(0, n // 2 - b), min(a, n // 2) + 1):
			answer.append(2 * a1 + b - n // 2)
		for a1 in range(max(0, n // 2 - b + 1), min(a, n // 2 + 1) + 1):
			answer.append(2 * a1 + b - n // 2 - 1)
		return sorted(answer)
t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	answer = process(a, b)
	print(len(answer))
	answer = ' '.join(map(str, answer)) + '\n'
	sys.stdout.write(answer)


count = int(input())
data = []
for i in range(count):
	y = [int(x) for x in input().split()]
	data.append(y)
for d in data:
	a = max(d)
	b = min(d)
	if a == b:
		print(a + 1)
		print(' '.join([str(2 * i) for i in range(a + 1)]))
	elif (a + b) % 2 == 0:
		vals = []
		for i in range(a - (a + b) // 2, (a + b) // 2 + 1):
			vals.append((a + b) // 2 - a + 2 * i)
		print(len(vals))
		print(' '.join([str(i) for i in sorted(vals)]))
	else:
		bserve = (a + b - 1) // 2
		aserve = bserve + 1
		n = a + b
		vals = []
		for i in range(a - bserve, aserve + 1):
			vals.append(bserve - a + 2 * i)
			vals.append(n - (bserve - a + 2 * i))
		print(len(vals))
		print(' '.join([str(i) for i in sorted(list(set(vals)))]))


import math
import os
import sys
from sys import *
from decimal import *
from io import BytesIO, IOBase
import itertools
from collections import *
import random
M = 10 ** 9 + 7
import heapq
import bisect
from functools import lru_cache
from queue import PriorityQueue
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def query1(l, r):
	if l >= r:
		return -1
	print('?', l + 1, r + 1)
	sys.stdout.flush()
	return int(input()) - 1

def answer(p):
	print('!', p + 1)
	sys.stdout.flush()
	exit()

def rse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(n)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(n)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def lse(arr, n):
	stack = []
	ans = []
	for i in range(n):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	return ans

def mah(arr):
	max1 = 0
	p = rse(arr, len(arr))
	q = lse(arr, len(arr))
	for i in range(len(arr)):
		a = (p[i] - q[i] - 1) * arr[i]
		max1 = max(a, max1)
	return max1

def maxSumIS(arr, n):
	msis = arr.copy()
	for i in range(1, n):
		for j in range(i):
			if arr[i] > arr[j] and msis[i] < msis[j] + arr[i]:
				msis[i] = msis[j] + arr[i]
	c = max(msis)
	p = 5
	return c

def binarysearch2(arr, target):
	lo = 0
	hi = len(arr) - 1
	while lo <= hi:
		mid = (lo + hi) // 2
		if arr[mid] == target:
			if mid != len(arr) - 1:
				if arr[mid + 1] != target:
					return mid
				else:
					lo += 1
			else:
				return mid
			continue
		if arr[mid] > target:
			hi = mid - 1
		else:
			lo = mid + 1

def nge(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] < arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def alperm(nums, path, result):
	if not nums:
		result.add(tuple(path))
		return
	for i in range(0, len(nums)):
		alperm(nums[:i] + nums[i + 1:], path + [nums[i]], result)
	return result

def minsum(arr, n, m, res, l):
	if n == 1 and m == 1:
		res += arr[0][0]
		l.append(res)
	else:
		if n != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n - 1, m, p, l)
		if m != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n, m - 1, p, l)
	return min(l)

def find_shortest_path(graph, start, end, path):
	path = path + [start]
	if start == end:
		return path
	if start not in graph:
		return None
	shortest = None
	for node in graph[start]:
		if node not in path:
			newpath = find_shortest_path(graph, node, end, path)
			if newpath:
				if not shortest or len(newpath) < len(shortest):
					shortest = newpath
	return shortest

def find(arr, i):
	while i != arr[i]:
		i = arr[i]
		arr[i] = arr[arr[i]]
	return i

def union(i, j, parent):
	(u, v) = (find(parent, i), find(parent, j))
	if u != v:
		parent[u] = v

def test(n, d):
	a = random.randint(1, n - 2)
	p = pow(a, d, n)
	if p == 1 or p == n - 1:
		return True
	while d != n - 1:
		d *= 2
		p = pow(p, 2, n)
		if p == n - 1:
			return True
	return False

def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	if n == 3:
		return True
	d = n - 1
	while d % 2 == 0:
		d //= 2
	for i in range(5):
		if test(n, d) == False:
			return False
	return True

def main():
	t = 1
	t = inpu()
	for _ in range(t):
		(a, b) = sep()
		(a, b) = (max(a, b), min(a, b))
		mx = (a + b) // 2
		if (a + b) % 2 != 0:
			mx += 1
		n = a + b
		st = a - mx
		ans = []
		ans.append(st)
		ans.append(n - st)
		for i in range(b):
			st = st + 2
			if st > n:
				break
			ans.append(st)
			ans.append(n - st)
		ans = list(set(ans))
		ans.sort()
		print(len(ans))
		print(*ans)
main()


import math
from itertools import permutations
t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	posibles = set()
	p = []
	for i in range(a):
		p.append(1)
	for i in range(b):
		p.append(0)
	if abs(a - b) == 1:
		for i in range(a + b + 1):
			posibles.add(i)
	elif a == b:
		for i in range(0, a + b + 1, 2):
			posibles.add(i)
	elif a % 2 == 1 and b % 2 == 1 or (a % 2 == 0 and b % 2 == 0):
		n = 0
		tmp = 0
		if a > b:
			n = (a - b) // 2
			tmp = b // 2 + 1
		else:
			n = (b - a) // 2
			tmp = a // 2 + 1
		tmp = tmp * 2
		counter = 0 + (a % 2 == 0 and b % 2 == 0)
		for i in range(n, a + b, 2):
			posibles.add(i)
			counter += 1
			if counter == tmp:
				break
	else:
		n = 0
		small = 0
		tmp = 0
		if a > b:
			n = (a - b) // 2
			tmp = b // 2 + 1
			small = b
		else:
			n = (b - a) // 2
			tmp = a // 2 + 1
			small = a
		counter = 0
		for i in range(n, a + b):
			posibles.add(i)
			counter += 1
			if counter >= (small + 1) * 2:
				break
	print(len(posibles))
	s = ''
	p = sorted(posibles)
	for i in range(len(p) - 1):
		print(p[i], end=' ')
	print(p[len(p) - 1])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = [int(c) for c in input().split()]
	d = abs(a - b) // 2
	if (a + b) % 2 == 0:
		ans = list(range(d, a + b - d + 1, 2))
	else:
		ans = list(range(d, a + b - d + 1, 1))
	print(len(ans))
	print(*ans)


t = int(input())
for k in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 1:
		m1 = abs(a - b) // 2
		m2 = a + b - abs(a - b) // 2
		print(m2 - m1 + 1)
		for i in range(m1, m2 + 1):
			print(i, end=' ')
		print()
	else:
		m1 = abs(a - b) // 2
		m2 = a + b - abs(a - b) // 2
		print((m2 - m1) // 2 + 1)
		for i in range(m1, m2 + 1, 2):
			print(i, end=' ')
		print()


import math
from collections import *
from functools import lru_cache
import bisect
inf = float('inf')
ip = input

def ipl():
	return list(map(int, input().split()))

def ipn():
	return int(input())

def ipf():
	return float(input())

def solve():
	(a, b) = ipl()
	n = a + b
	k = set()
	for i in range(min(a, b) + 1):
		if n % 2 == 0:
			r = n // 2 - min(a, b) + i * 2
			k.add(r)
		else:
			k.add(n // 2 - min(a, b) + i * 2)
			k.add(n // 2 - min(a, b) + i * 2 + 1)
	print(len(k))
	for i in sorted(list(k)):
		print(i, end=' ')
	print()
for _ in range(int(input())):
	solve()


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, func=lambda a, b: a & b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	(a, b) = map(int, input().split())
	ans = set()

	def find(x):
		totala = (a + b + 1) // 2
		totalb = (a + b) // 2
		y = b - x
		x1 = totala - y
		y1 = a - x1
		if x1 >= 0 and 0 <= y1 <= totalb and (y >= 0) and (0 <= x <= totalb):
			ans.add(y + y1)

	def find1(x):
		totalb = (a + b + 1) // 2
		totala = (a + b) // 2
		y = b - x
		x1 = totala - y
		y1 = a - x1
		if x1 >= 0 and 0 <= y1 <= totalb and (y >= 0) and (0 <= x <= totalb):
			ans.add(y + y1)
	for i in range(a + b + 1):
		find(i)
		find1(i)
	print(len(ans))
	ans = sorted(ans)
	print(*ans)


import sys
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
depth = 1000005
mod = 1000000007
lim = mod * mod
sys.setrecursionlimit(depth)
from math import inf, ceil, sqrt
from collections import defaultdict
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	tot = a + b
	(odd, evn) = ((tot + 1) // 2, tot // 2)
	ans = set()
	for i in range(0, a + 1):
		oddplace = i
		evnplace = a - i
		if oddplace > odd:
			continue
		if evnplace > evn:
			continue
		remodd = odd - oddplace
		remevn = evn - evnplace
		breaks = evnplace + remodd
		ans.add(breaks)
	(odd, evn) = (tot // 2, (tot + 1) // 2)
	for i in range(0, a + 1):
		oddplace = i
		evnplace = a - i
		if oddplace > odd:
			continue
		if evnplace > evn:
			continue
		remodd = odd - oddplace
		remevn = evn - evnplace
		breaks = evnplace + remodd
		ans.add(breaks)
	print(len(ans))
	ans = list(ans)
	ans.sort()
	print(*ans)


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = set()
	if (n + m) % 2 == 0:
		x = (n + m) // 2
		for i in range(x + 1):
			r = n - i
			r2 = x - (n - i)
			if r >= 0 and r2 >= 0:
				ans.add(i + r2)
	else:
		x = (n + m) // 2
		for i in range(x + 1):
			r = n - i
			r2 = n + m - x - (n - i)
			if r >= 0 and r2 >= 0:
				ans.add(i + r2)
		for i in range(x + 2):
			r = n - i
			r2 = n + m - (x + 1) - (n - i)
			if r >= 0 and r2 >= 0:
				ans.add(i + r2)
	ck = sorted(ans)
	print(len(ck))
	print(*ck)


t = int(input())
m = [0] * t
k = [[] for i in range(t)]

def change_num(num):
	if num % 2 == 0:
		return [0] + [num]
	else:
		return list(set([1] + [num]))
for case in range(t):
	(a, b) = [int(i) for i in input().split()]
	if a == b:
		k[case] = [i for i in range(0, a + b + 1, 2)]
		m[case] = len(k[case])
	elif abs(a - b) % 2 == 0:
		m[case] = max(a, b) - abs(a - b) + 1
		k[case] = [i for i in range(abs(a - b) // 2, int((max(a, b) - (abs(a - b) + abs(a - b) // 2) / 2) * 2 + 1), 2)]
	else:
		m[case] = a + b + 2 - abs(a - b)
		k[case] = [i for i in range(abs(a - b) // 2, abs(a - b) // 2 + m[case])]
for i in range(t):
	print(m[i])
	temp = k[i]
	temp = list(set(temp))
	temp.sort()
	for j in range(len(temp)):
		print(temp[j], end='')
		if j != len(temp) - 1:
			print(' ', end='')
	print()


from __future__ import division, print_function
import math
import sys
import os
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	(a, b) = invr()
	n = a + b
	if n % 2:
		mn = abs(b - a) // 2
		mx = n - abs(b - a) // 2
		print(mx - mn + 1)
		for i in range(mn, mx + 1):
			print(i, end=' ')
		print()
	else:
		mn = abs(b - a) // 2
		mx = n - abs(b - a) // 2
		print((mx - mn) // 2 + 1)
		for i in range(mn, mx + 1, 2):
			print(i, end=' ')
		print()


import os
import sys
from io import BytesIO, IOBase
import math
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')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def f(i):
	if a[i] > a[i + 1]:
		(a[i], a[i + 1]) = (a[i + 1], a[i])
for t in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		ans = [i for i in range(0, 2 * a + 1, 2)]
		print(len(ans))
		print(*ans)
	elif abs(a - b) == 1:
		print(a + b + 1)
		print(*[i for i in range(a + b + 1)])
	elif (a + b) % 2 == 0:
		ans = [i for i in range(0 + abs(a - b) // 2, 1 + a + b - abs(a - b) // 2, 2)]
		print(len(ans))
		print(*ans)
	else:
		ans = [i for i in range(0 + abs(a - b) // 2, 1 + a + b - abs(a - b) // 2)]
		print(len(ans))
		print(*ans)


from sys import stdin
input = stdin.readline
from math import ceil

def answer():
	ans = set()
	(x, y) = (ceil((a + b) / 2), (a + b) // 2)
	br = max(a - x, 0) + max(b - y, 0)
	if a > b:
		left = b
	else:
		left = a
	for i in range(left + 1):
		ans.add(br + 2 * i)
	(x, y) = ((a + b) // 2, ceil((a + b) / 2))
	br = max(a - x, 0) + max(b - y, 0)
	if a > b:
		left = b
	else:
		left = a
	for i in range(left + 1):
		ans.add(br + 2 * i)
	print(len(ans))
	ans = sorted(list(ans))
	return ans
for T in range(int(input())):
	(a, b) = map(int, input().split())
	print(*answer())


import sys
import math
from collections import Counter
input = sys.stdin.readline
N = 1000000007
for _ in range(int(input().strip())):
	(a, b) = [int(j) for j in input().strip().split()]
	n = a + b
	ans = []
	if n % 2 != 0:
		c = n // 2
		if a < b:
			first = c - a
			last = n - first
			ans = [i for i in range(first, last + 1)]
		else:
			first = c - b
			last = n - first
			ans = [i for i in range(first, last + 1)]
	else:
		c = n // 2
		if a < b:
			first = c - a
			last = n - first
			ans = [i for i in range(first, last + 1, 2)]
		else:
			first = c - b
			last = n - first
			ans = [i for i in range(first, last + 1, 2)]
	print(len(ans))
	print(*ans)


import sys
import math
for _ in range(int(sys.stdin.readline())):
	(a, b) = map(int, sys.stdin.readline().split())
	if a > b:
		(a, b) = (b, a)
	small = math.floor((a + b) / 2)
	big = math.ceil((a + b) / 2)
	ans = set()
	start = b - big
	end = a + b - start
	for i in range(start, end, 2):
		if i not in ans:
			ans.add(i)
	for i in range(end, start - 1, -2):
		if i not in ans:
			ans.add(i)
	ans = list(ans)
	ans.sort()
	print(len(ans))
	print(*ans)


import math
import heapq
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	(a, b) = M()
	if a > b:
		(a, b) = (b, a)
	l = []
	n = a + b
	(p, q) = (n // 2, n // 2 + n % 2)
	for k in range(a + b + 1):
		s = max(0, k - q)
		t = min(k, p)
		(x, y) = (p + k - a, k + a - q)
		if x % 2 == 0 and s <= x // 2 <= t or (y % 2 == 0 and s <= y // 2 <= t):
			l.append(k)
	print(len(l))
	print(*l)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	g = a + b
	if g % 2 != 0:
		x = g // 2
		y = x + 1
		ans = []
		s = x - min(a, b)
		e = y + min(a, b)
		print(e + 1 - s)
		for i in range(s, e):
			print(i, end=' ')
		print(e)
	elif g % 2 == 0:
		x = g // 2
		y = g // 2
		s = x - min(a, b)
		e = y + min(a, b)
		ans = []
		j = s
		while j <= e:
			ans.append(j)
			j += 2
		print(len(ans))
		for i in ans[:-1]:
			print(i, end=' ')
		print(ans[-1])


cnt = int(input())
for _ in range(cnt):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	diff = a - b
	min_breaks = diff // 2
	a -= 2 * min_breaks
	could_be_odd = a > b
	next_games = a + b
	possibilities = [str(min_breaks + i) for i in range(next_games + 1) if could_be_odd or i % 2 == 0]
	print(len(possibilities))
	print(' '.join(possibilities))


T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split(' '))
	if b < a:
		(a, b) = (b, a)
	R = set()
	if (a + b) % 2 == 1:
		xa = (a + b) // 2 + 1
		xb = (a + b) // 2
		for breaka in range(a + 1):
			breakb = xa - (a - breaka)
			R.add(breaka + breakb)
		xa = (a + b) // 2
		xb = (a + b) // 2 + 1
		for breaka in range(a + 1):
			breakb = xa - (a - breaka)
			R.add(breaka + breakb)
	else:
		xa = xb = (a + b) // 2
		for breaka in range(a + 1):
			breakb = xa - (a - breaka)
			R.add(breaka + breakb)
	R = list(R)
	R.sort()
	print(len(R))
	print(' '.join((str(r) for r in R)))