def count(a, b): return b.bit_length()-a.bit_length() def solve(A, B): res = [] n = count(A, B) v = B >> n for i in range(A.bit_length()): if (A >> i) & 1 and not (v >> i) & 1: res.append(1 << i) A += 1 << i n = count(A, B) v = B >> n for i in range(A.bit_length()-1, -1, -1): if ((A ^ v) >> i) & 1: res.append(1 << i) A += 1 << i for i in range(n-1, -1, -1): res.append(A) A <<= 1 if (B >> i) & 1: res.append(1) A += 1 return res T = int(input()) ans = [] for _ in range(T): A, B = map(int, input().split()) ans.append(solve(A, B)) for a in ans: print(len(a)) print(*a)