#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a < b) {
			cout << a;
			for (int j = a+1; j <= b; j++) {
				cout << " " << j;
			}
			cout << endl;
		} else {
			if (a < 6) {
				cout << a;
				for (int j = a-1; j >= b; j--) {
					cout << " " << j;
				}
				cout << endl;
			} else {
				if (b < 6) {
					cout << a;
					for (int j = a+1; j <= 9; j++) {
						cout << " " << j;
					}
					for (int j = 5; j >= b; j--) {
						cout << " " << j;
					}
					cout << endl;
				} else {
					cout << a;
					for (int j = a+1; j <= 9; j++) {
						cout << " " << j;
					}
					for (int j = 5; j >= 1; j--) {
						cout << " " << j;
					}
					for (int j = 0; j <= b; j++) {
						cout << " " << j;
					}
					cout << endl;
				}
			}
		}
	}
	return 0;
}