#include <iostream>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

char v[] ="0123456789543210123456789";

void solve(int s,int g) {
    int ans = 10000;
    int p = 0;
    rep(i,25){
        if(v[i] != s+'0') continue;
        loop(j,i+1,25){
            if(v[j] == g + '0') {
                ans = min(ans,j-i);
                p = i;
                continue;
            }
        }
    }

    for(int i=p; i<=p+ans; i++) cout<< (i==p?"":" ") <<v[i];
    cout << endl;
}

int main() {
    int n; cin >> n;
    rep(i,n){
        int f, t;
        cin >> f >> t;
        solve(f,t);
    }
}