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

int main() {
	string sa = "012345678954321012345678954321";
	int n;
	cin >> n;
	for (int x = 0;x < n;x++) {
		char a, b;
		cin >> a >> b;
		int aa=1e-9, ab=1e9;
		for (int i = 0;i < sa.size();i++) {
			if (sa[i] == a) {
				for (int j = i;j <= sa.size();j++) {
					if (sa[j] == b) {
						if (ab - aa > j - i) {
							aa = i;
							ab = j;
						}
					}
				}
			}
		}
		for (int i = aa; i <= ab;i++) {
			if (i != aa)cout << ' ';
			cout << sa[i];
		}
		cout << endl;
	}
	return 0;
}