#include<iostream>
#include<vector>
using namespace std;


int main(){
  int bus[20],index;
  for(int i=0;i<=9;i++)bus[i]=i;
  index=10;
  for(int i=5;i>=0;i--)bus[index++]=i;
  //for(int i=0;i<16;i++)cout << bus[i] << " ";
  //cout << endl;
  int n,st,ed,rs;
  cin >> n;
    vector<int> perm,vec;
    bool giveway;
    for(int k=0;k<n;k++){
      perm.clear();vec.clear();
      giveway = false;
      cin >> st >> ed;
      rs = st;
      
      while(st != ed){

	perm.push_back(st);
	if(!giveway)st++;
	if(giveway)st--;
	if(!giveway &&st == 10){
	  st = 5;
	  giveway = true;
	}
	else if(giveway && st == 0){
	  giveway = false;
	}
      }
      giveway = false;
      perm.push_back(ed);
     
      if(1<=rs && rs<=5){
     
	while(rs != ed){
	  vec.push_back(rs);
	  if(!giveway)rs--;
	  if(giveway)rs++;
	  if(!giveway &&rs == 0){
	    giveway = true;
	  }
	  else if(giveway && rs == 10){
	    rs = 5;
	    giveway = false;
	  }
	}
  vec.push_back(ed);
      if(perm.size() > vec.size() )perm = vec;
      }
    
  
      for(int i=0;i<perm.size();i++){
	cout << perm[i];
	i == perm.size()-1 ? cout << endl:cout << " ";
      }


    }

  
  return 0;
}