#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int way[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

int s,g;
vector<int> w1,w2;
vector<int> ss;

void solve(){
	w1.clear();
	w2.clear();
	ss.clear();
	REP(i,15){
		if (way[i]==s){
			ss.push_back(i);
		}
	}
	if (ss.size()==1){
		int v=ss[0];
		while (way[v]!=g){
			printf("%d ",way[v]);
			v++;
			v%=15;
		}
		printf("%d\n",g);
		return;
	}
	int v=ss[0];
	while (way[v]!=g){
		w1.push_back(way[v]);
		v++;
		v%=15;
	}
	w1.push_back(g);
	v=ss[1];
	while (way[v]!=g){
		w2.push_back(way[v]);
		v++;
		v%=15;
	}
	w2.push_back(g);
	if (w1.size()<w2.size()){
		REP(i,(int)w1.size()){
			if (i) printf(" ");
			printf("%d",w1[i]);
		}
		printf("\n");
	}else{
		REP(i,(int)w2.size()){
			if (i) printf(" ");
			printf("%d",w2[i]);
		}
		printf("\n");
	}
}

int main(){
	int n;
	cin>>n;
	REP(i,n){
		cin>>s>>g;
		solve();
	}
	return 0;
}