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


string bus = "012345678954321012345678954321";
int start,end;

void solve(){
  if(start < end){
    for(int i = start; i <= end; i++){
      if(i != start) cout << " ";
      cout << bus[i];
    }
  }else{
    for(int i = 6;; i++){
      if(bus[i]-'0' == start){
	start =i;
	break;
      }
    }

    for(int i = start;;i++){
      if(i != start) cout << " ";
      cout << bus[i];
      if(bus[i] -'0' == end) break;
    }
  }
}

int main(){
  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    cin >> start >> end;
    solve();
    cout << endl;
  }
  return 0;
}