#include<iostream>
#include<vector>
using namespace std;

int K[15] = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1 };
int s, t, n, c, ok, q;
vector<int>x[15];
vector<int>p;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 15; j++) {
			x[j].clear();
		}
		p.clear();
		c = -1; ok = 0; q = 1145141919;
		cin >> s >> t;
		for (int j = 0; j < 15; j++) {
			if (K[j] == s) {
				for (int k = j; k < 15 + j; k++) {
					x[j].push_back(K[k % 15]);
					if (K[k % 15] == t) {
						break;
					}
				}
			}
		}
		for (int j = 0; j < 15; j++) {
			if (q > x[j].size() && x[j].size() >= 1) {
				q = x[j].size();
				p = x[j];
			}
		}
		for (int j = 0; j < p.size(); j++) {
			if (j >= 1) {
				cout << ' ';
			}
			cout << p[j];
		}
		cout << endl;
	}
}