#include <iostream>
using namespace std;

int main(){
	int togo[10][2] = {{1,1},{0,2},{1,3},{2,4},{3,5},{4,6},{7,7},{8,8},{9,9},{5,5}};
	int a,b,n,l,r,c,d;
	cin >> n;
	for(int i = 0;i < n;++i){
		c = 0;d = 1;
		cin >> a >> b;
		l = r = a;
		while(l != b && r != b){
			l = togo[l][c];
			r = togo[r][d];
			if(!l) c = 1 - c;
			if(!r) d = 1 - d;
		}
		c = 0;d = 1;
		cout << a;
		while(a != b){
			if(l == b){
				a = togo[a][c];
				if(!a) c = 1 - c;
			}
			else{
				a = togo[a][d];
				if(!a) d = 1 - d;
			}
			cout << " " << a;
		}
		cout << endl;
	}
	return 0;
}