#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf( "%d\n", &n );
    for( int j = 0; j < n; j++ )
    {
        int source = 0, sink = 0;
        scanf( "%d %d\n", &source, &sink );
        if( source <= 5 )
        {
            if( source < sink )
            {
                for( int i = source; i <= sink; i++ )
                {
                    printf( "%d ", i );
                }
                printf( "\n" );
            }
            else
            {
                for( int i = source; i >= sink; i-- )
                {
                    printf( "%d ", i );
                }
                printf( "\n" );
            }
        } 
        else
        {
            if( sink >= 5 )
            {
                if( source < sink )
                {
                    for( int i = source; i <= sink; i++ )
                    {
                        printf( "%d ", i );
                    }
                    printf( "\n" );
                }
                else
                {
                    for( int i = source; i <= 9; i++ )
                    {
                        printf( "%d ", i );
                    }
                    if( sink != 5 )
                    {
                        printf( "5 4 3 2 1 0 1 2 3 4" );
                    }
                    for( int i = 5;i < sink; i++ )
                    {
                        printf( "%d ", i );
                    }
                    printf( "\n" );
                }
            }
            else
            {
                for( int i = source; i <= 9; i++ )
                {
                    printf( "%d ", i );
                }
                for( int i = 5; i >= sink; i++ )
                {
                    printf( "%d ", i );
                }
                printf( "\n" );
            }
        }
    }
    return 0;
}
