#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<20)
int G[20];
int search(int s,int f){
  if(s==-1) return INF;
  int count;
  for(int i=0;i<15;i++){
    int ind = (i+s)%15;
    //   printf("%d\n",G[ind]);
    if(G[ind] == f){
      count = i;
      break;
    }
  }
  return count;
}
void printans(int s,int f){
  for(int i=0;i<15;i++){
    int ind = (i+s)%15;
    printf("%d",G[ind]);
    if(G[ind] == f){
      break;
    }
    printf(" ");
  }
  puts("");
}
int main(){
  int n;
  for(int i=0;i<10;i++) G[i]=i;
  for(int i=10,j=5;i<15;i++,j--) G[i]=j;
  scanf("%d\n",&n);
  for(int i=0;i<n;i++){
    int s,f;
    scanf("%d %d",&s,&f);
    int count = 0;
    int st=-1;
    count = search(s,f);
    for(int i=10;i<15;i++){
      if(G[i]==s){ 
	st = i;
      }
    }
    if(st>0){
      if(count < search(st,f)){
	printans(s,f);
      }else{
	printans(st,f);
      }
    }else{
      printans(s,f);
    }
  }
}