#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;

string nor = "6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9";
string rev = "9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 9 8 7 6";
int n;
string getstr(string str, char s, char d){
	int i,j;
	for(i=0;str[i]!=s;i++);
	for(j=i;str[j]!=d;j++) if(str[j]==s) i=j;
	return str.substr(i, j-i+1);
}
main(){
	int n,a,b;
	cin >> n;
	while(n--){
		string ret1, ret2;
		cin >> a >> b;
		ret1 = getstr(nor, a+'0', b+'0');
		ret2 = getstr(rev, a+'0', b+'0');
		cout << (ret1.size()<ret2.size()?ret1:ret2) << endl;
	}
	return 0;
}