#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<int> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        int ans = INF<int>, jj = 0, kk = 0;
        for (int j = 0; j < v.size(); ++j) {
            for (int k = j+1; k < v.size(); ++k) {
                if(v[j] == a && v[k] == b){
                    if(ans > abs(j-k)){
                        ans = abs(j-k);
                        jj = j; kk = k;
                    }
                }
            }
        }
        for (int j = jj; j <= kk; j++) {
            if(j != jj) printf(" ");
            printf("%d", v[j]);
            if(j == kk) break;
        }
        puts("");
    }
    return 0;
}
