n = gets.to_i
n.times do
    x = gets
    y = x.split(" ")
    inbus = y[0].to_i
    outbus = y[1].to_i
    if inbus < outbus
        num = []
        for i in inbus..outbus do
            num << i
        end
            puts num.join(" ")
    elsif inbus > outbus
        if inbus <= 5
            num = []
            for i in outbus..inbus do
                num << i
            end
                puts num.reverse.join(" ")
        elsif inbus >= 6
            if outbus <= 5
            num = []
            for i in inbus..9 do
                num << i
            end
            if outbus == 5
                num << 5
            elsif outbus == 4
                num << 5
                num << 4
            elsif outbus == 3
                num << 5
                num << 4
                num << 3
            elsif outbus == 2
                num << 5
                num << 4
                num << 3
                num << 2
            elsif outbus == 1
                num << 5
                num << 4
                num << 3
                num << 2
                num << 1
            elsif outbus == 0
                num << 5
                num << 4
                num << 3
                num << 2
                num << 1
                num << 0
            end
            puts num.join(" ")
            elsif outbus >= 6
            num = []
             for i in inbus..9 do
                 num << i
             end
             num << 5
             num << 4
             num << 3
             num << 2
             num << 1
             num << 0
             num << 1
             num << 2
             num << 3
             num << 4
             
             for i in 5..outbus do
                 num << i
             end
                 
          puts num.join(" ")
              
                 
        end
        
            
        end
    end
end

