bus = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(eval(input())):

    s, t = list(map(int, input().split()))

    if s>5:

        print(" ".join(map(str, bus[s:bus.index(t, s)+1])))

    else:

        if s<t:

            print(" ".join(map(str, range(s, t+1))))

        else:

            print(" ".join(map(str, range(s, t-1, -1))))

            
bus = "0123456789543210123456789"

rbus = "543210"

for i in range(eval(input())):

    s, t = input().split()

    if t<s<'6':

        left = rbus.find(s, 0)

        right = rbus.find(t, left)

        print(" ".join(rbus[left:right+1]))

    else:

        left = bus.find(s, 0)

        right = bus.find(t, left)

        print(" ".join(bus[left:right+1]))
bus = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(eval(input())):
    s, t = list(map(int, input().split()))
    if s > 5:
        print(" ".join(map(str, bus[s : bus.index(t, s) + 1])))
    else:
        if s < t:
            print(" ".join(map(str, range(s, t + 1))))
        else:
            print(" ".join(map(str, range(s, t - 1, -1))))

bus = "0123456789543210123456789"
rbus = "543210"
for i in range(eval(input())):
    s, t = input().split()
    if t < s < "6":
        left = rbus.find(s, 0)
        right = rbus.find(t, left)
        print(" ".join(rbus[left : right + 1]))
    else:
        left = bus.find(s, 0)
        right = bus.find(t, left)
        print(" ".join(bus[left : right + 1]))

-bus = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +bus = "0123456789543210123456789" +rbus = "543210" -    s, t = list(map(int, input().split())) -    if s > 5: -        print(" ".join(map(str, bus[s : bus.index(t, s) + 1]))) +    s, t = input().split() +    if t < s < "6": +        left = rbus.find(s, 0) +        right = rbus.find(t, left) +        print(" ".join(rbus[left : right + 1])) -        if s < t: -            print(" ".join(map(str, range(s, t + 1)))) -        else: -            print(" ".join(map(str, range(s, t - 1, -1)))) +        left = bus.find(s, 0) +        right = bus.find(t, left) +        print(" ".join(bus[left : right + 1]))