def lscan; gets.split.map(&:to_i); end def solve(a, b) answer = [] step = 1 while a < b if b - a == step answer << step a += step elsif b - a < step step /= 2 elsif b - a > step*2 if a%(step*2) == 0 step *= 2 else answer << step a += step end else answer << step a += step end end answer end # def check(a, b, ans) # p a # ans.each do |x| # abort "#{x}" unless a%x == 0 # p a += x # end # abort `#{a} != #{b}` unless a == b # true # end gets.to_i.times do a,b = lscan ans = solve(a, b) p ans.size puts ans*' ' # p check(a, b, ans) end