LastStation = 9

def solve start, dest
  result = Array.new
  result << current = start
  up = (! (start <= 5 && dest < start)) ? true : false

  while current != dest
    if up
      current += 1
    else
      current -= 1
    end

    if current >  LastStation
      current = 5
      up = false
    end
    if current < 0
      current = 1
      up = true
    end
    
    result << current
  end

  result
end

$stdin.gets.to_i.times do
  start, dest = $stdin.gets.chomp.split(" ").map(&:to_i)
  result = solve(start, dest)
  first = true
  result.each do |s|
    printf " " unless first
    printf "%d", s
    first = false
  end
  printf "\n"
end