#include<algorithm>
#include<iostream>
#include<string>

const std::string bstop = "012345678954321";

int main()
{
	int n;
	std::cin >> n;
	while( n-- )
	{
		int s, e;
		std::cin >> s >> e;
		
		bool fl = false;
		std::string ans;

		while( true )
		{
			for( int i = 0; i != bstop.size(); ++i )
			{
				if( fl )
				{
					ans += ' ';
					ans += bstop[i];
				}

				if( bstop[i] == s + '0' )
				{
					ans.clear();
					fl = true;
					ans = bstop[i];
				}

				if( fl && bstop[i] == e + '0' )
					goto end;
			}
		}
end:;
		std::cout << ans << std::endl;
	}

	return 0;
}