n = gets.to_i
n.times do
  stop1, stop2 = gets.split.map(&:to_i)
  route = (stop1 < stop2 ? (stop1..stop2) : (stop2..stop1)).to_a
  case stop1
  when 0..5
    route.reverse! if stop2 < stop1
  when 6..9
    if (0..5).include?(stop2)
      route = (stop1..9).to_a + (stop2..5).to_a.reverse!
    elsif stop2 < stop1
      route = (stop1..9).to_a + (0..5).to_a.reverse! + (1..4).to_a + (5..stop2).to_a
    end
  end

  puts route.join(' ')
end