#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int from, to;
		scanf("%d %d", &from, &to);
		if (to > from)
		{
			for (int i = from; i < to; ++i)
				printf("%d ", i);
			printf("%d\n", to);
		}
		else
		{
			if (from >= 6)
			{
				for (int i = from; i <= 9; ++i)
					printf("%d ", i);

				if (to >= 6 && to < from)
				{
					for (int i = 5; i > 0; --i)
						printf("%d ", i);
					for (int i = 0; i < to; ++i)
						printf("%d ", i);
					printf("%d\n", to);
					continue;
				}
				else
					from = 5;
			}
			for (int i = from; i > to; --i)
				printf("%d ", i);
			printf("%d\n", to);
		}
	}

	return 0;
}