#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;//入力
int main()
{
  cin >>n;
  for(int i = 0;i < n;i++){
    int start;
    int finish;
    int ans;
    bool flag;
    cin >>start>>finish;
    if(start >5&&finish <=5){
      cout <<start;
      cout <<" ";
      ans = start;
      for(int j = 1;j <=(9-ans);j++){
	cout <<++start;
	cout <<" ";
      }
    for(int j = 5;j !=finish;j--){
      cout <<j;
      cout <<" ";
    }
    cout <<finish<<endl;
    continue;
    }
    if(start >6&&finish >5&&finish <start){
      cout <<start;
      cout <<" ";
      ans = start;
      for(int j = 1;j <=(9-ans);j++){
	cout<<++start;
	cout <<" ";
      }
      for(int j = 5; j!=-1;j--){
	cout <<j;
	cout <<" ";
      }
      for(int j = 1;j <finish;j++){
	cout <<j;
	cout <<" ";
      }
      cout <<finish<<endl;
      continue;
    }
    if(finish >start){
      ans = finish-start;
      flag =true;
    }
    else if(finish <start){
      ans = start-finish;
      flag =false;
    }
  
    if(flag){
    cout <<start;
    cout <<" ";
    for(int j = 1;j <ans;j++){
      cout <<++start;
      cout <<" ";
    }
    cout <<finish<<endl;
    }
    else if(!flag){
      cout <<start;
      cout <<" ";
      for(int j = 1;j <ans;j++){
	cout <<--start;
	cout <<" ";
      }
      cout <<finish<<endl;
    }
  }
  return 0;
}