import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): t = int(input()) for _ in range(t): a, b = map(int, input().split()) target = 0 for i in reversed(range(60)): if not(a & (1 << i)) and b & (1 << i): target = i break cnt = 0 res = [] for i in range(60): if a & (1 << target): break elif a & (1 << i): cnt += 1 res.append(1 << i) a += (1 << i) for i in range(60): if not (a & (1 << i)) and (b & (1 << i)): cnt += 1 a += (1 << i) res.append(1 << i) print(cnt) print(*res) if __name__ == '__main__': resolve()