ss = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1]
gets.to_i.times do
  a, b = gets.split.map(&:to_i)
  rs = []
  ss.each_with_index do |s, i|
    next unless s == a
    rs << []
    j = i
    loop do
      rs.last << ss[j]
      break if ss[j] == b
      j += 1
      j %= ss.size
    end
  end
  puts rs.min_by(&:size).join ' '
end