#include <iostream>
#include <vector>

using namespace std;

int line[15];

void init() {
    for (int i = 0; i < 14; i++) {
        line[i] = i+1;
    }
    line[14] = 0;
}

int main() {
    init();
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int s, g; cin >> s >> g;
        vector<int> path;
        int as = s;
        int ag = g;
        if (1 <= s && s <= 5) as = 15 - s;
        if (1 <= g && g <= 5) ag = 15 - g;

        int c = s;
        while (c != g && c != ag) {
            path.push_back(c);
            c = line[c];
        }
        path.push_back(g);

        if (as != s) {
            vector<int> opath;
            c = as;
            while (c != g && c != ag) {
                opath.push_back(c);
                c = line[c];
            }
            opath.push_back(g);
            if (path.size() > opath.size()) {
                path.resize(opath.size());
                copy(opath.begin(), opath.end(), path.begin());
            }
        }

        if (path[0] >= 10) {
            cout << 15 - path[0];
        } else {
            cout << path[0];
        }
        for (int j = 1; j < path.size(); j++) {
            if (path[j] >= 10) {
                cout << ' ' << 15 - path[j];
            } else {
                cout << ' ' << path[j];
            }   
        }
        cout << endl;
    }
    return 0;
}