#include<iostream>
using namespace std;
int main(){
long n,s,e,i,j;
cin>>n;
for(j=0;j<n;j++){
cin>>s>>e;
if(s<6){
if(e<6){
if(s<e){cout<<s;for(i=s+1;i<=e;i++)cout<<" "<<i;cout<<endl;}
else{cout<<s;for(i=s-1;i>=e;i--)cout<<" "<<i;cout<<endl;}
}else{
cout<<s;for(i=s+1;i<=e;i++)cout<<" "<<i;cout<<endl;
}
}else{
if(e<6){
cout<<s;
for(i=s+1;i<=9;i++)cout<<" "<<i;
for(i=5;i>=e;i--)cout<<" "<<i;cout<<endl;
}else{
if(s<e){cout<<s;for(i=s+1;i<=e;i++)cout<<" "<<i;cout<<endl;}
else{
cout<<s;
for(i=s+1;i<=9;i++)cout<<" "<<i;
for(i=5;i>=0;i--)cout<<" "<<i;
for(i=1;i<=e;i++)cout<<" "<<i;cout<<endl;
}
}
}
}
return 0;
}