#include<iostream>
using namespace std;

int main()
{
  int n;
  int s,g;
  int add;
  cin>>n;
  while(n-->0){
    cin>>s>>g;
    add=1;

    if(s<=g){
      cout<<s;
      while(s!=g){
	s+=add;
	cout<<" "<<s;
      }
    }else{
      if(s<=5)add=-1;
      cout<<s;
      while(s!=g){
	if(s==9){
	  s=6;
	  add=-1;
	}
	if(s==0){
	  s=0;
	  add=1;
	}
	s+=add;
	cout<<" "<<s;
      }
    }
    puts("");
  }
}