#include <iostream>
using namespace std;

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

int main(){
	int n,s,g,count,k,a;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> s >> g;
		count = 1000000000;
		for(int j = 0;j < 15;++j){
			if(busstop[j] == s){
				int tmp = 0;
				k = j;
				while(busstop[k] != g){
					++k;
					k%=15;
					++tmp;
				}
				if(tmp < count){
					count = tmp;
					a = j;
				}
			}
		}
		while(busstop[a] != g){
			cout << busstop[a++] << " ";
			a  %= 15;
		}
		cout << g << endl;
	}
	return 0;
}