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

int BusStop[] ={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
int Offset[]={0,13,11,9,7,5};
vector<int> Result1, Result2;
	
int main(void){
    int n,start,end,i,j;
    
    cin>>n;
    while(n--){
        cin>>start>>end;
        Result1.clear();
        Result2.clear();
        if(start>5 || start==0){	//0 || 6:9
			for(int i=start; BusStop[i%15]!=end; i++){
				cout<<BusStop[i%15]<<" ";
			}
		}else{
			int i=start, j=start+Offset[i]; 
			while(1){
				if(BusStop[i%15] == end){
					for(int k=0; k<Result1.size(); k++){
						cout<<Result1[k]<<" ";
					}
					break;
				}
				if(BusStop[j%15] == end){
					for(int k=0; k<Result2.size(); k++){
						cout<<Result2[k]<<" ";
					}
					break;
				}
				Result1.push_back(BusStop[i%15]);
				Result2.push_back(BusStop[j%15]);
				i++;
				j++;
			}
		}
		cout<<end<<endl;
    }
	
    return 0;
}
