#include <string>
#include <iostream>
using namespace std;
int n, x, y; string s = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2 1";
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		string t = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2 1";
		for(int i = 0; i < s.size(); i += 2) {
			for(int j = i + 2; j < s.size(); j += 2) {
				if(s[i] == x + 48 && s[j] == y + 48 && j - i + 1 < t.size()) {
					t = s.substr(i, j - i + 1);
				}
			}
		}
		cout << t << endl;
	}
}