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

int busstop[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};

int main(){
	int n,s,g;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> s >> g;
		if(s <= 5 && g <= 5){
			if(s < g){
				while(s != g){
					cout << s++ << " ";
				}
				cout << g << endl;
			}
			else{
				while(s != g){
					cout << s-- << " ";
				}
				cout << g << endl;
			}
		}
		else if(s <= 5 && g <= 9){
			while(s != g){
				cout << s++ << " ";
			}
			cout << g << endl;
		}
		else{
			while(busstop[s] != g){
				cout << busstop[s++] << " ";
			}
			cout << g << endl;
		}
	}
	return 0;
}