#include <iostream>
using namespace std;

int stop[15] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};

int main() {
    int n;
    cin >> n;
    while (n--) {
        int a, b;
        cin >> a >> b;
        int i;
        if (a > 5 || a < b) {
            cout << stop[a];
            for (i = a + 1; stop[i] != b; i = (i + 1) % 15) {
                cout << " " << stop[i];
            }
            cout << " " << stop[i];
            cout << endl;
        } else {
            cout << stop[15 - a];
            for (i = 15 - a + 1; stop[i] != b; i = (i + 1) % 15) {
                cout << " " << stop[i];
            }
            cout << " " << stop[i];
            cout << endl;
        }
    }
    return 0;
}