#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#define P pair<int,int>
using namespace std;

int main() {
	int bus[] = { 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,0 };
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d;
		scanf("%d%d", &c, &d);
		vector<int>l(100);
		for (int e = 0; e < 14; e++) {
			if (bus[e] == c) {
				vector<int>f;
				for (int g = e; g < 30; g++) {
					f.push_back(bus[g]);
					if (bus[g] == d)break;
				}
				if (f.size() < l.size())l = f;
			}
		}
		for (int x = 0; x < l.size(); x++) {
			if (x)printf(" ");
			printf("%d", l[x]);
		}
		puts("");
	}
}