#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a[15] = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1 };
	int s, t;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s >> t;
		int sum = 100000, sum2 = 100000, s2 = s,count=0;
		bool sumb = false, sum2b = false;
		vector<int> go;
		vector<int>go2;
		for (int j = 0; j < 15; j++)
		{
			if (a[j] == s) {
				s2 = j;
				while (a[s2] != t) {
					if (count == 0) {
						if (!sumb) {
							sum = 0; sumb = true;
						}
						go.push_back(a[s2]);
						sum++;
					}
					else {
						if (!sum2b) {
							sum2 = 0; sum2b = true;
						}
						go2.push_back(a[s2]);
						sum2++;
					}
					s2++;
					if (s2 > 14) s2 = 0;
				}
				if (count == 0) {
					go.push_back(t);
					sum++;
				}
				else {
					go2.push_back(t);
					sum2++;
				}
				count++;
				s2 = s;
			}
		}
		if (sum < sum2) {
			for (int i = 0; i < sum; i++) {
				if (i == 0) cout << go[i];
				else cout << " " << go[i];
			}
			cout << endl;
		}
		else {
			for (int i = 0; i < sum2; i++) {
				if (i == 0) cout << go2[i];
				else cout << " " << go2[i];
			}
			cout << endl;
		}
	}
}