#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;

#define INF 999999999

int gcd(int x, int y) {
	if (x % y == 0)return y;
	else return gcd(y, x%y);
}

int lcm(int x, int y) {
	return x*y / gcd(x, y);
}

int main() {
	list<int> bus = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		int c = INF, d;
		vector<vector<int> > path;
		for (auto itr = bus.begin(); itr != bus.end(); itr++) {
			if (*itr == a) {
				vector<int> tmp;
				for (auto itrr = itr; *itrr != b; itrr++) {
					tmp.push_back(*itrr);
					auto tmp = itrr;
					if (++tmp == bus.end())itrr = bus.begin();
				}
				tmp.push_back(b);
				path.push_back(tmp);
				if (c > tmp.size()) {
					c = tmp.size();
					d = path.end() - path.begin() - 1;
				}
			}
		}
		for (int i = 0; i + 1 < path[d].size(); i++) {
			cout << path[d][i] << " ";
		}
		cout << b << endl;
	}
	return 0;
}
