#include<iostream>
using namespace std;
void p(int x,int y){
 
  cout<<x;
  for(int i=x+1;i<=y;i++){
    cout<<' '<<i;
  }
  
}
void pb(int x,int y){
  cout<<x;
  for(int i=x-1;i>=y;i--){
    cout<<' '<<i;
  }

}
int main(){
  int n,a,b;
  cin>>n;
  while(n--){
    cin>>a>>b;
    if(a<=5&&b<=5){
      if(a<b)p(a,b);
      else {
	
	pb(a,b);
      }
      cout<<endl;
    }else if(a<=5&&b>=6){

      if(a<=4){p(a,4);cout<<' ';}
      p(5,b);
      cout<<endl;

    }else if(a>=6&&b<=5){

      p(a,9);cout<<' ';
      pb(5,b);cout<<endl;

    }else{
      
      if(a<=b){
	p(a,b);cout<<endl;
      }else{
	p(a,9);cout<<' ';
	pb(5,0);cout<<' ';
	p(1,4);cout<<' ';
	p(5,b);cout<<endl;
      }

    }
  }
  
}