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

const int INT = -1;
int nextstop[10][2] = {{1,1},{0,2},{1,3},{2,4},{3,5},{4,6},{INT,7},{INT,8},{INT,9},{INT,5}};

int main(){
	int n,start,goal,a,k;
	vector<int> rout;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> start >> goal;
		for(int j = 0;j < 2;++j){
			k = j;
			a = start;
			rout.clear();
			while(a != goal){
				rout.push_back(a);
				a = nextstop[a][k];
				if(a == -1 || a == 0){
					break;
				}
				else if(j == 1 && rout[rout.size() - 1] == 9) k = 1 - k;
			}
			if(a == goal) {
				rout.push_back(a);
				break;
			}
		}
		for(int j = 0;j < rout.size();++j){
			if(j) cout << " ";
			cout << rout[j];
		}
		cout << endl;
	}
	return 0;
}