#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int a,b;
	cin>>a>>b;
	if(a<b){
	  bool h=false;
	  loop(i,a,b+1){
	    if(h)cout<<" ";
		h=true;
		cout<<i;
      }
	}else if(a<=5){
	  bool h=false;
	  for(int i=a;i>b-1;i--){
	    if(h)cout<<" ";
		h=true;
		cout<<i;
	  }
	}else if(b<=5){
	  bool h=false;
	  loop(i,a,10){
	    if(h)cout<<" ";
		h=true;
		cout<<i;
      }
	  for(int i=5;i>b-1;i--)cout<<" "<<i;
	}else{
	  bool h=false;
	  loop(i,a,10){
	    if(h)cout<<" ";
		h=true;
		cout<<i;
      }
	  for(int i=5;i>0;i--)cout<<" "<<i;
	  rep(i,b+1)cout<<" "<<i;
	}
	cout<<endl;
  }
}