#include <iostream>

using namespace std;


int main(void){
	int s,e,n;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> s >> e;
		cout << s;
		if(s <= 5){
			if(e < s){
				for(int j=s-1;j>=e;j--){
					cout << " " << j;
				}
				cout << endl;
			}else{
				for(int j=s+1;j<=e;j++){
					cout << " " << j;
 				}
 				cout << endl;
			}
		}else{
			if(e >= 6){
				if(s < e){
					for(int j=s+1;j<=e;j++){
						cout << " " << j;
					}
					cout << endl;
				}else{
					for(int j=s+1;j<=9;j++){
						cout << " " << j;
					}
					for(int j=5;j<=e;j++){
						cout << " " << j;
					}
					cout << endl;
				}
			}else{
				for(int j=s+1;j<=9;j++){
					cout << " " << j;
				}
				for(int j=5;j>=e;j--){
					cout << " " << j;
				}
				cout << endl;
			}
		}
	}

}