#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int i, j, n, before, after;
  vector<int> line, way;
  vector<int>::iterator iter1, iter2;

  for(i=0; i<10; ++i)
    line.push_back(i);
  for(i=5; i>=0; --i)
    line.push_back(i);

  for(i=0; i<line.size(); ++i)
    cout << line[i] << " ";
  cout << endl;

  cin >> n;

  for(i=0; i<n; ++i){
    cin >> before >> after;
    
    if(before < after){
      iter1 = find(line.begin(), line.begin()+10, before);
      iter2 = find(iter1, line.begin()+10, after);
    }else{
      iter1 = find(line.begin()+6, line.end(), before);
      iter2 = find(iter1, line.end(), after);
    }
    copy(iter1, iter2+1, back_inserter(way));

    for(j=0; j<way.size()-1; ++j)
      cout << way[j] << " ";
    cout << way[way.size()-1] << endl;

    way.clear();
  }

  return 0;
}