#include <iostream>
using namespace std;

int main() {
	int n, src, dir = 1, dst, spc;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> src >> dst;
		spc = 0;
		if(src<dst || (src>dst && src>=6))dir = 1;
		else dir = -1;
		int j=0;
		do{
			if(src+j>9){
				j=5-src;
				dir = -1;
			}
			if(spc++ != 0)cout << " ";
			cout << src+j;
		}while(src+(dir>0 ? j++ : j--)!=dst);
		cout << endl;
	}
	// your code goes here
	return 0;
}
