#include<iostream>
using namespace std;

const int stop[31] = {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};
int main()
{
	int n;
	cin >> n;
	for(int x=0;x<n;x++){
		int a,b;
		cin >> a >> b;
		bool flag = false;
			for(int i=0;i<31;i++){
				if(stop[i] == a){
					for(int k=i;k<31;k++){
						if(stop[k] == b)
							break;
						else if(stop[k] == a)
							i = k;
					}
					for(int j=i;j<31;j++){
						if(stop[j] != b)
							cout << stop[j] << " ";
						else{
							cout << stop[j] << endl;
							flag = true;
							break;
						}
					}
				}
				if(flag)
					break;
			}
	}
	return 0;
}