#include <iostream>

using namespace std;

int main()
{
	int s, t, d, n;
	cin >> n;
	
	while(n--){
		cin >> s >> t;
		d = (t < s && s <= 5)? -1 : 1;
		while(t != s){
			cout << s << " ";
			s += d;
			if(s == 10){
				d = -1;
				s = 5;
			} else if(s == -1){
				d = 1;
				s = 1;
			}
		}
		cout << t << endl;
	}
	
	return 0;
}