#include <iostream>
using namespace std;

int main(){
	int n,s,g;
	int seq[]={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};
	cin >> n;
	
	while(n--){
		cin >> s >> g;
		for(int i=0;i<32;i++){
			if(s<=5 && s>g){
				if(seq[10+i]==s){
					for(int j=10+i;j<32;j++){
						if(j!=10+i)cout << " ";
						cout << seq[j];
						if(seq[j]==g)break;
					}
					cout << endl;
					break;
				}
			}else{
				if(seq[i]==s){
					for(int j=i;j<32;j++){
						if(j!=i)cout << " ";
						cout << seq[j];
						if(seq[j]==g)break;
					}
					cout << endl;
					break;
				}
			}
		}
	}
}