T = gets.to_i def solver(a, b) ans = [] la = a.bit_length lb = b.bit_length l = [*0...lb].reverse.find { |i| a[i] != b[i] } l.times do |i| if a[i] == 1 ans << 2.pow(i) a += 2.pow(i) end end (lb - 2).downto(0) do |i| if b[i] == 1 && a[i] == 0 ans << 2.pow(i) a += 2.pow(i) end end puts ans.size puts ans.join(' ') end T.times do a, b = gets.split.map(&:to_i) solver(a, b) end