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 res1 = [] for i in range(60): if a & (1 << target): break elif a & (1 << i) and a + (1 << i) <= b: cnt += 1 res1.append(1 << i) a += (1 << i) res2 = [] for i in range(60): if not (a & (1 << i)) and (b & (1 << i)) and a + (1 << i) <= b: cnt += 1 a += (1 << i) res2.append(1 << i) res = res1 + res2[::-1] print(cnt) print(*res) if __name__ == '__main__': resolve()