#include <iostream>
using namespace std;
const int field[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8};
const int l = sizeof(field) / sizeof(int);

int main() {
	int n;
	cin >> n;
	while (n--) {
		int s, g;
		int res_size = 100, res_begin;
		cin >> s >> g;
		for (int i = 0; i < l; i++) {
			if (field[i] != s) continue;
			for (int j = i + 1; j < l; j++) {
				if (field[j] != g) continue;
				int size = j - i;
				if (size < res_size) {
					res_size = size;
					res_begin = i;
				}
			}
		}
		for (int i = res_begin;; i++) {
			if (i != res_begin) cout << ' ';
			cout << field[i];
			if (field[i] == g) break;
		}
		cout << endl;
	}
	return 0;
}