#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
  int n;
  cin >> n;
  while(n--) {
    int s,g;
    cin >> s >> g;
    vector<int> v;
    if (s<g)
      for (int i=s;i<=g;i++)
        v.push_back(i);
    else if (s<6&&g<6) {
      for (int i=s;i>=g;i--)
        v.push_back(i);
    } else if (g<6&&s>=6) {
      for (int i=s;i<=9;i++) {
        v.push_back(i);
      }
      for (int i=5;i>=g;i--) {
        v.push_back(i);
      }
    } else if (s>=6&&g>=6) {
      for (int i=s;i<=9;i++) {
        v.push_back(i);
      }
      for (int i=5;i>=0;i--) {
        v.push_back(i);
      }
      for (int i=1;i<=g;i++)
        v.push_back(i);
    }
    REP(i,v.size()) {
      if (i) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
}