#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    int N;
    cin >> N;
    for (;N--;) {
        int src, dst;
        cin >> src >> dst;

        if (src < dst) {
            cout << src;
            for (int j = src+1; j <= dst; ++j) {
                cout << ' ' << j;
            }
            cout << endl;
        } else {
            cout << src;
            if (src <= 5) {
                for (int j = src-1; j >= dst; --j) {
                    cout << ' ' << j;
                }
            } else {
                for (int j = src+1; j <= 9; ++j) {
                    cout << ' ' << j;
                }
                if (dst <= 5) {
                    for (int j = 5; j >= dst; --j) {
                        cout << ' ' << j;
                    }
                } else {
                    for (int j = 5; j <= dst; ++j) {
                        cout << ' ' << j;
                    }
                }
            }
            cout << endl;
        }

    }

    return 0;
}