#include <iostream>
#include <queue>
using namespace std;

int n;
queue<int> Q, R;

int main()
{
    for(int i = 0; i < 10; i++)
        Q.push(i);

    for (int i = 5; i > 0; i--)
        Q.push(i);

    cin >> n;

    for (int i = 0; i < n; i++) {
        int a, b;

        cin >> a >> b;

        int c = Q.front();

        while (c != a) {
            Q.push(c);
            Q.pop();
            c = Q.front();
        }

        if (a == 0 || a > 5) {
            while (c != b) {
                cout << c << " ";
                Q.push(c);
                Q.pop();
                c = Q.front();
            }
        }
        else {
            R.push(c);
            Q.push(c);
            Q.pop();
            c = Q.front();

            while (c != b && c != a) {
                R.push(c);
                Q.push(c);
                Q.pop();
                c = Q.front();
            }

            if (c == a) {
                while (c != b) {
                    cout << c << " ";
                    Q.push(c);
                    Q.pop();
                    c = Q.front();
                }
            }
            else {
                while (!R.empty()) {
                    cout << R.front() << " ";
                    R.pop();
                }
            }
        }

        cout << b << endl;
    }

    return 0;
}

