from math import gcd t=int(input()) for _ in range(t): a,b=map(int,input().split()) op=[] while b-a>=2: if a%2==0 and b%2==0: op.append(2) a//=2 b//=2 elif a%2==0: op.append(-1) b-=1 elif b%2==0: op.append(1) a+=1 else: op.append(1) op.append(-1) a+=1 b-=1 if b-a==1: op.append(1) by=1 plus=[] minus=[] for num in op: if num==1: plus.append(by) elif num==-1: minus.append(by) else: by*=num ANS=plus+minus print(len(ANS)) print(*ANS)