#include <iostream>
#include <string>

using namespace std;
string bus_stop = "0123456789543210123456789543210123456789543210";

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		char s, g;
		cin >> s >> g;
		string ans1, ans2;
		bool flag = false;
		int pos = 0;
		for(int i = 0; i < bus_stop.size(); ++i)
		{
			if(!flag && bus_stop[i] == s)
			{
				flag = true;
				pos = i;
			}
			if(flag)
			{
				ans1 += bus_stop[i];
				if(bus_stop[i] == g)
				{
					break;
				}
			}
		}
		flag = false;
		for(int i = pos + 1; i < bus_stop.size(); ++i)
		{
			if(bus_stop[i] == s)
			{
				flag = true;
			}
			if(flag)
			{
				ans2 += bus_stop[i];
				if(bus_stop[i] == g)
				{
					break;
				}
			}
		}
		if(ans1.size() < ans2.size())
		{
			cout << ans1[0];
			for(int i = 1; i < ans1.size(); ++i)
			{
				cout << " " << ans1[i];
			}
			cout << endl;
		}
		else
		{
			cout << ans2[0];
			for(int i = 1; i < ans2.size(); ++i)
			{
				cout << " " << ans2[i];
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}