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

void downTo(vector<int> &vs, int s, int t) {
    while (t <= s) {
        vs.push_back(s--);
    }
}

void upTo(vector<int> &vs, int s, int t) {
    while (s <= t) {
        vs.push_back(s++);
    }
}

int main() {
    int n;
    while (cin >> n) {
        while (n--) {
            int s, t;
            cin >> s >> t;
            vector<int> ans;
            if (s <= 5) {
                if (s < t) {
                    upTo(ans, s, t);
                } else {
                    downTo(ans, s, t);
                }
            } else {
                if (s < t) {
                    upTo(ans, s, t);
                } else {
                    upTo(ans, s, 9);
                    if (t < 5) {
                        downTo(ans, 5, t);
                    } else {
                        upTo(ans, 5, t);
                    }
                }
            }
            cout << ans[0];
            for (int i = 1, size = ans.size(); i < size; i++) {
                cout << " " << ans[i];
            }
            cout << endl;
        }
    }
}