#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		int start, goal;
		cin >> start >> goal;
		if(0 <= start && start <= 5)
		{
			if(0 <= goal && goal <= 5)
			{
				cout << start;
				if(start < goal)
				{
					for(int i = start + 1; i <= goal; ++i)
					{
						cout << " " << i;
					}
					cout << endl;
				}
				else
				{
					for(int i = start - 1; i >= goal; --i)
					{
						cout << " " << i;
					}
					cout << endl;
				}
			}
			else if(goal == 6 || goal == 7)
			{
				cout << start;
				for(int i = start + 1; i <= goal; ++i)
				{
					cout << " " << i;
				}
				cout << endl;
			}
			else if(goal == 8 || goal == 9)
			{
				cout << start;
				for(int i = start + 1; i <= 5; ++i)
				{
					cout << " " << i;
				}
				for(int i = 8; i <= goal; ++i)
				{
					cout << " " << i;
				}
				cout << endl;
			}
		}
		else
		{
			cout << start;
			for(int i = start + 1; i <= 9; ++i)
			{
				cout << " " << i;
				if(i == goal)
				{
					goto NEXT;
				}
			}
			if(goal <= 5)
			{
				for(int i = 5; i >= goal; --i)
				{
					cout << " " << i;
				}
			}
			else
			{
				for(int i = 5; i >= 0; --i)
				{
					cout << " " << i;
				}
				for(int i = 1; i <= goal; ++i)
				{
					cout << " " << i;
				}
			}
NEXT:
			cout << endl;
		}
	}
}

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