#include<iostream>
using namespace std;

int main(){
  int n,f,t,m,num;
  int line[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};

  cin >> n;
  while(n--){
    cin >> f >> t;

    m = 30;
    num = -1;
    for(int i=0;i<=30;i++){
      if(line[i] == f){
	for(int j=i+1;j<=30;j++){
	  if(line[j] == t){
	    if(m>j-i){
	      m = j-i;
	      num = i;
	    }
	  }
	}
      }
    }

    for(int i=num;i<num+m;i++)cout << line[i] << " ";
    cout << line[num+m] << endl;
  }
}