#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	int n, s, t;
	int r[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	cin >> n;
	rep(i,n) {
		cin >> s >> t;
		if(s<=5&&t<=5&&s>t) {
			for(int i=s;i>t;--i) cout << i << " ";
			cout << t << endl;
		} else {
			rep(i,15) {
				if(r[i]==s) {
					rep(j,15) {
						if(r[(i+j)%15]==t) break;
						cout << r[(i+j)%15] << " ";
					}
					cout << t << endl;
					break;
				}
			}
		}
	}
	return 0;
}