T = int(input()) for _ in range(T): A, B = map(int, input().split()) ans = [] nokori = 120 while A != B: while 2 * A <= B: ans.append(A) A *= 2 nokori -= 1 if B - A <= nokori: ans.extend([1] * (B - A)) break ind = 1 while A != B: # print(A, B, ans, sum(ans)) two = 2 ** ind # if (B - A)//(two//2) <= nokori: # ans.extend([two//2] * ((B - A)//(two//2) )) # break if A % two == 0: if A + A // two <= B: ans.append(A // two) A += A // two nokori -= 1 ind = 1 break else: ind += 1 else: A += two // 2 nokori -= 1 ans.append(two // 2) print(len(ans)) print(*ans)