#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int N; cin >> N;
    while(N--) {
        int from, to; cin >> from >> to;
        vector<int> route;
        if(from <= 5 && to < from) {
            for(int i = from; i >= to; i--) {
                route.push_back(i);
            }
        }
        else {
            if(from >= 6 && to >= 6 && to < from) {
                for(int i = from; i <= 9; i++) {
                    route.push_back(i);
                }
                for(int i = 5; i >= 0; i--) {
                    route.push_back(i);
                }
                for(int i = 1; i <= 5; i++) route.push_back(i);
                for(int i = 6; i <= to; i++) route.push_back(i);
            }
            else if(from >= 6 && to <= 5) {
                for(int i = from; i <= 9; i++) {
                    route.push_back(i);
                }
                for(int i = 5; i >= to; i--) {
                    route.push_back(i);
                }
            }
            else {
                for(int i = from; i <= to; i++) {
                    route.push_back(i);
                }
            }
        }
        for(int i = 0; i < (int)route.size() - 1; i++) cout << route[i] << ' ';
        cout << *route.rbegin() << endl;
    }
}