#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

#define rep(i, n)for((i) = 0;(i) < (n);++(i))

string x = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 ";

int main(void){
	x += x;
	int n, i, s, t, l, r;
	pair<int,string> res;
	scanf("%d", &n);
	for(;n--;){
		res.first = 12345;
		scanf("%d %d", &s, &t);
		rep(l, x.size())if(x[l] == '0' + s){
			for(r = l + 1;r < x.size();++r)if(x[r] == '0' + t)break;
			if(r < x.size() && res.first > r - l){
				res.first = r - l + 1;
				res.second = x.substr(l, r - l + 1);
			}
		}
		cout << res.second << endl;
	}
	return 0;
}