#include <iostream>
#include <vector>

using namespace std;


int main(int argc, char const* argv[])
{
	int n;
	int start,end;
	vector<int> answer;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> start >> end;
		answer.clear();

		if( start < end ){
			for( int j = start;j <= end;j++ ) answer.push_back( j );
		} else {
			if( start <= 5 ){
				for( int j = start;j >= end;j-- ) answer.push_back( j );
			} else if( end > 5 ) {
				for( int j = start;j < 10;j++ ) answer.push_back( j );
				for( int j = 5;j >= 0;j-- ) answer.push_back( j );
				for( int j = 1;j <= end;j++ ) answer.push_back( j );
			} else {
				for( int j = start;j < 10;j++ ) answer.push_back( j );
				for( int j = 5;j >= end;j-- ) answer.push_back( j );
			}
		}

		for( unsigned int i = 0;i < answer.size();i++ ) cout << ( ( i == 0 ) ? "" : " " ) << answer[i];
		cout << endl;
	}


	return 0;
}