def main(): from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython ''' ''' for _ in range(int(input())): A,B = map(int, input().split()) ans = [] dgt = 0 while A+pow(2,dgt) <= B: if (A>>dgt)&1: tmp = pow(2,dgt) A += tmp ans.append(tmp) dgt += 1 print(bin(A)) print(bin(B)) for i in reversed(range(60)): if (B>>i)&1 and (~A>>i)&1: ans.append(pow(2,i)) A += pow(2,i) print(len(ans)) print(*ans) if __name__ == '__main__': main()