#include<iostream>
#include<vector>
using namespace std;

int main(){
	int n;
	cin>>n;
	int busstop[15]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	for(int i=0;i<n;i++){
		int start,stop,l,j;
		vector<int> ans1,ans2;
		cin>>start>>stop;
		for(l=start;busstop[l%15]!=stop;l++){
			ans1.push_back(busstop[l]);
			if(l==0)l=-1;
		}
		ans1.push_back(busstop[l]);
		for(j=15-start;busstop[j%15]!=stop;j++){
			ans2.push_back(busstop[j]);
			if(j==14)j=-1;
		}
		ans2.push_back(busstop[j]);
		if(ans1.size()<ans2.size()){
			for(int k=0;k<(ans1.size()-1);k++){
				cout<<ans1[k]<<" ";
			}
			cout<<ans1[ans1.size()-1]<<endl;
		}else{
			for(int k=0;k<(ans2.size()-1);k++){
				cout<<ans2[k]<<" ";
			}
			cout<<ans2[ans2.size()-1]<<endl;
		}
	}
	return 0;
}