T = int(input()) AB = [list(map(int,input().split())) for _ in range(T)] for a,b in AB: ans = [] k = 0 a2 = a a3 = a while a2 % 2 == 0: k += 1 a2 //= 2 ad = pow(2,k) while b >= a + ad and a2 > 1: ans.append(ad) a += ad a2 += 1 while a2 % 2 == 0: k += 1 a2 //= 2 ad = pow(2,k) while b >= 2 * a and a2 == 1: ans.append(ad) a *= 2 k += 1 ad = pow(2,k) while b > a: if b >= a +ad: a += ad ans.append(ad) if k > 0: k -= 1 ad = pow(2,k) print(len(ans)) print(*ans) for a0 in ans: #print(a3,a0,a3 % a0) a3 += a0