#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 = 0, sum2 = 0, s2 = s;
		vector<int> go;
		vector<int>go2;
		while (a[s2] != t) {
			go.push_back(a[s2]);
			sum++;
			s2++;
			if (s2 > 14) s2 = 0;
		}
		go.push_back(t);
		sum++;
		s2 = s;
		while (a[s2] != t) {
			go2.push_back(a[s2]);
			sum2++;
			s2--;
			if (s2 < 0) s2 = 14;
		}
		go2.push_back(t);
		sum2++;
		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;
		}
	}
}