#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> VI;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define PB( n ) push_back( n )

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

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

	REP( dt, 0, t )
	{
		int a, b;
		cin >> a >> b;

		VI r, l;
		int i, j;

		i = a;
		for ( j = i; Stop[j] != b; j++ )
		{
			if ( 15 <= j )
			{
				j = 0;
			}

			r.PB( Stop[j] );
		}
		r.PB( Stop[j] );

		i = a;
		for ( j = i; Stop[j] != b; j-- )
		{			
			if ( j < 0 )
			{
				j = 14;
			}

			l.PB( Stop[j] );
		}
		l.PB( Stop[j] );

		VI res = ( l.size() < r.size() ? l : r );

		UREP( i, 0, res.size() )
		{
			cout << res[i] << ( i + 1 == res.size() ? '\n' : ' ' );
		}
	}

	return 0;
}