#include<iostream>
#include<string>
using namespace std;

void printRes( string s )
{
    for( int i = 0; i < s.size() - 1; i++ )
        cout << s[i] << " ";
    cout << s[s.size()-1] << endl;
}

int main()
{
    int n, a[24], x, y;
    string s, t;

    for( int i = 0; i < 10; i++ )
        a[i] = i;
    for( int i = 10; i < 16; i++ )
        a[i] = 15 - i;
    for( int i = 16; i < 24; i++ )
        a[i] = i - 15;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        s = "";
        t = "";
        cin >> x >> y;

        if( 6 <= x && x <= 9 )
        {
            for( int j = x; j < 24; j++ )
            {
                s += a[j] + '0';
                if( a[j] == y )
                    break;
            }
            printRes( s );
        }
        else
        {
            bool judge1 = false, judge2 = false;
            for( int j = x; j >= 0; j-- )
            {
                s += a[j] + '0';
                if( a[j] == y )
                {
                    judge1 = true;
                    break;
                }
            }

            for( int j = x; j < 16; j++ )
            {
                t += a[j] + '0';
                if( a[j] == y )
                {
                    judge2 = true;
                    break;
                }
            }

            if( s.size() < t.size() )
            {
                if( judge1 == 1 )
                    printRes( s );
                else
                    printRes( t );
            }
            else
            {
                if( judge2 == 1 )
                    printRes( t );
                else
                    printRes( s );
            }
        }
    }
    return 0;
}
