#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;

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

void solve( int s, int t )
{
    if ( s >= 0 && s <= 5 && t >= 0 && t <= 5 )
    {
        if ( s > t )
        {
            for ( int i = s; i >= t; i-- )
            {
                cout << i;
                if ( i == t ) cout << endl; else cout << " ";
            }
            return;
        }
        else
        {
            for ( int i = s; i <= t; i++ )
            {
                cout << i;
                if ( i == t ) cout << endl; else cout << " ";
            }
            return;
        }
    }

    int k = 0;
    for ( k = 0; k < 15; k++ ) if ( route[k] == s ) break;
    while ( route[k] != t )
    {
        cout << route[k] << " ";
        k = ( k + 1 ) % 15;
    }
    cout << route[k] << endl;;
}

int main( void )
{

    int n;
    cin >> n;

    for ( int i = 0; i < n; i++ )
    {
        int s, t;
        cin >> s >> t;
        solve( s, t );
    }

    return 0;
}