#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

const static char *BUSLINE = "012345678954321";
const static int BUSLINE_LEN = 15;

int main() {
  int n;
  cin >> n;
  
  for( int i = 0; i < n; i++ ) {
    int ent, ext;
    int route = 1;
    vector<int> route1, route2;
    cin >> ent >> ext;

    for( int j = 0; j < BUSLINE_LEN; j++ ) {
      if( BUSLINE[ j ] == ent + '0' ) {
        for( int k = j; ; k = ( k + 1 ) % BUSLINE_LEN ) {
          if( route == 1 ) {
            route1.push_back( BUSLINE[ k ] - '0' );
          } else {
            route2.push_back( BUSLINE[ k ] - '0' );
          }
          if( BUSLINE[ k ] == ext + '0' ) {
            route++;
            break;
          }
        }
      }
    }

    vector<int>* vp;
    if( route2.size() == 0 || route1.size() < route2.size() ) {
      vp = &route1;
    } else {
      vp = &route2;
    }
    
    int len = vp->size();
    for( int i = 0; i < len; i++ ) {
      cout << vp->at(i) << flush;
      if( i == len - 1 ) { break; }
      cout << " " << flush;
    }
    cout << endl;
  }

  return EXIT_SUCCESS;
}