#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int n, s, t;
int stops[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0};
vector<int> ss1, ss2;
bool flag1, flag2;

int main()
{
	cin >> n;

	REP(n)
	{
		cin >> s >> t;
		
		ss1.clear();
		ss2.clear();

		flag1 = flag2 = false;

		//printf("s = %d, t = %d\n", s, t);

		if (0 <= s && s <= 5)
		{
			for (int j=s; j<16; j++)
			{
				ss1.pb(stops[j]);
				if (stops[j] == t)
				{
					flag1 = true;
					break;
				}
			}
			for (int j=15-s; j<16; j++)
			{
				ss2.pb(stops[j]);
				if (stops[j] == t)
				{
					flag2 = true;
					break;
				}
			}
		} else {
			for (int j=s; j<16; j++)
			{
				ss1.pb(stops[j]);
				if (stops[j] == t)
				{
					flag1 = true;
					break;
				}
			}
		}

		//printf("ss1.size = %d, ss2.size = %d\n", ss1.size(), ss2.size());

		if (flag1 && ss1.size() != 0 && ss2.size() != 0 && ss1.size() < ss2.size())
		{
			rep(j, ss1.size())
			{
				cout << ss1[j];
				cout << ((j != ss1.size() - 1) ? " " : "\n");
			}
		}
		if (flag2 && ss1.size() != 0 && ss2.size() != 0 && ss2.size() < ss1.size())
		{
			rep(j, ss2.size())
			{
				cout << ss2[j];
				cout << ((j != ss2.size() - 1) ? " " : "\n");
			}
		}
		if (flag1 && ss1.size() != 0 && ss2.size() == 0)
		{
			rep(j, ss1.size())
			{
				cout << ss1[j];
				cout << ((j != ss1.size() - 1) ? " " : "\n");
			}
		}
		if (flag2 && ss1.size() == 0 && ss2.size() != 0)
		{
			rep(j, ss2.size())
			{
				cout << ss2[j];
				cout << ((j != ss2.size() - 1) ? " " : "\n");
			}
		}
		if (flag1 && ss1.size() == ss2.size())
		{
			rep(j, ss1.size())
			{
				cout << ss1[j];
				cout << ((j != ss1.size() - 1) ? " " : "\n");
			}
		}
		if (flag2 && ss1.size() == ss2.size())
		{
			rep(j, ss2.size())
			{
				cout << ss2[j];
				cout << ((j != ss2.size() - 1) ? " " : "\n");
			}
		}
	}
	
	return 0;
}