#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;

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

    while(--n >= 0){
        int a, b;
        cin >> a >> b;

        int i[2], j[2];
        i[0] = find(buss, buss+15, a) - buss;
        i[1] = find(buss+i[0]+1, buss+15, a) - buss;
        j[0] = find(buss, buss+15, b) - buss;
        j[1] = find(buss+j[0]+1, buss+15, b) - buss;

        int x, y;
        int len = INT_MAX;
        for(int k=0; k<2; ++k){
            for(int l=0; l<2; ++l){
                if(i[k] == 15 || j[l] == 15)
                    continue;
                int tmp = (j[l] - i[k] + 15) % 15;
                if(tmp < len){
                    len = tmp;
                    x = i[k];
                    y = j[l];
                }
            }
        }

        cout << buss[x];
        do{
            ++ x;
            x %= 15;
            cout << ' ' << buss[x];
        }while(x != y);

        cout << endl;
    }

    return 0;
}