#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i,n) for (int i = 0; i < (n); ++i)


vector<int> R;
int main() {
    int s, g;
    string ans;

    rep(i, 10) {
        R.push_back(i);
    }
    for(int i=5; i>0; --i) {
        R.push_back(i);
    }
    int n;
    cin >> n;

    rep(re, n) {
        cin >> s >> g;
        bool start = false, goal = false;

        while (1) {
            for(int i=0; i<15; ++i) {
                if(start) {
                    ans += " ";
                    ans += to_string(R[i]);
                }

                if(R[i] == s) {
                    ans.clear();
                    ans += to_string(R[i]);
                    start = true;
                }

                if (R[i] == g && start) {
                    goal = true;
                    break;
                }
            }

            if (goal) break; //もし最後にたどり着いても終わっていなかったらまた最初に折り返す．
        }
        cout << ans << endl;
    }

}


