#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		if(a < b){
			for(int j = a;j <= b;j++) cout << (j == a ? "" : " ") << j;
		}else if(a >= 6){
			for(int j = a;j <= 9;j++) cout << (j == a ? "" : " ") << j;
			if(b >= 6) {
				for(int j = 5;j >= 0;j--) cout << " " << j;
				for(int j = 1;j <= b;j++) cout << " " << j;
			}
			else for(int j = 5;j >= b;j--) cout << " " << j;
		}else{
			for(int j = a;j >= b;j--) cout << (j == a ? "" : " ") << j;
		}
		cout << endl;
	}
	return 0;
}