#include<iostream>

using namespace std;

int main()
{
	char s[]="0123456789543210";

	int n;	cin>>n;
	while(n--){
		int start,goal;	cin>>start>>goal;
		int ans=100,ans_st;
		for(int i=0;i<16;i++){
			if(s[i]!=start+'0')	continue;
			for(int j=i+1;j<16;j++){
				if(s[j]==goal+'0'){
					if(ans>j-i)	ans=j-i,ans_st=i;
				}
			}
		}
		for(int i=ans_st;;i++){
			cout<<(i==ans_st?"":" ")<<s[i];
			if(s[i]==goal+'0')	break;
		}
		cout<<endl;
	}

	return 0;
}