#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> way = {6, 7, 8, 9, 5, 4, 3, 2, 1, 0};
    for(int i = 0; i < n; i++)
    {
        int s, g; cin >> s >> g;
        if(s < g)
        {
            for(int i = s; i <= g; i++)
            {
                if(i != s) cout << " ";
                cout << i;
            }
        }
        else if(s <= 5 and g <= 5)
        {
            for(int i = s; i >= g; i--)
            {
                if(i != s) cout << " ";
                cout << i;
            }
        }
        else
        {
            int pos = s - 6;
            vector<int> ans;
            while(true)
            {
                ans.push_back(way[pos]);
                if(way[pos] == g) break;
                pos++;
                if(pos >= way.size())
                {
                    for(int i = 1; i <= g; i++) ans.push_back(i);
                    break;
                }
            }
            for(int i = 0; i < ans.size(); i++)
            {
                if(i) cout << " ";
                cout << ans[i];
            }
        }
        cout << endl;
    }
    return 0;
}


