#include <iostream>

using namespace std;

void print_stops(int from, int to) {
    if (from <= 5 && to <= 5) {
        if (from < to) {
            for (int i = from; i <= to; i++) {
                cout << i << ' ';
            }
        } else {
            for (int i = from; i >= to; i--) {
                cout << i << ' ';
            }
        }
    } else if (from <= 5 && 6 <= to && to <= 9) {
        for (int i = from; i <= to; i++) {
            cout << i << ' ';
        }
    } else if (6 <= from && from <= 9 && to <= 5) {
        for (int i = from; i <= 9; i++) {
            cout << i << ' ';
        }
        for (int i = 5; to <= i; i--) {
            cout << i << ' ';
        }
    } else if (6 <= from && from <= 9 && 6 <= to && to <= 9) {
        if (from < to) {
            for (int i = from; i <= to; i++) {
                cout << i << ' ';
            }
        } else {
            for (int i = from; to <= i; i++) {
                cout << i << ' ';
            }
        }
    }
    cout << endl;
}

int main() {
    int n; cin >> n;
    while (n--) {
        int from, to;
        cin >> from >> to;
        print_stops(from, to);
    }
    return 0;
}