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

vector<int> route = {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,5,4,3,2,1};

int main() {
    int n, s, t;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> s >> t;
        int m = route.size();
        int l = -1, r = -1;
        for (int j=1; j<=m; ++j) {
            for (int k=0; k+j-1<m; ++k) {
                if (route[k] == s && route[k+j-1] == t) {
                    l = k;
                    r = k+j-1;
                    break;
                }
            }
            if (0 <= l) {
                break;
            }
        }
        for (int i=l; i<=r; ++i) {
            cout << (i == l ? "" : " ") << route[i];
        }
        cout << endl;
    }
    return 0;
}