#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		int from,to;
		cin>>from>>to;
		if(from<to)for(int i=from;i<=to;++i)cout<<i<<((i==to)?"":" ");
		else if(from<=5)for(int i=from;i>=to;--i)cout<<i<<((i==to)?"":" ");
		else if(to<=5){
			for(int i=from;i<=9;++i)cout<<i<<((i==9)?"":" ");
			for(int i=5;i>=to;--i)cout<<" "<<i;
		}else{
			for(int i=from;i<=9;++i)cout<<i<<((i==9)?"":" ");
			for(int i=5;i<=to;++i)cout<<" "<<i;
		}
		cout<<"\n";
	}
	return 0;
}