import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) def calc(A, B): resR = [] resL = [] while A + A <= B: if B % 2 == 0: resR.append(B // 2) B //= 2 else: resR.append(1) B -= 1 while A + A <= B: resL.append(A) A += A cnt = 0 X = A while X % 2 == 0: cnt += 1 X >>= 1 dif = B - A while dif: for i in reversed(range(cnt + 1)): val = 1 << i if dif >= val: dif -= val resL.append(val) A += val if A % (val * 2) == 0: cnt = max(cnt, i + 1) break res = resL + resR[::-1] print(len(res)) print(*res, sep=" ") T = int(input()) query = tuple(tuple(map(int, input().split())) for _ in range(T)) for a, b in query: calc(a, b)