#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, a) for (int i = (a); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  //ios::sync_with_stdio(false);
  int n;

  cin >> n;
  
  for (;n--;){
    int a, b;
    cin >> a >> b;
    if (a < b){
      REPS(i, a, b + 1){
        printf("%d%c", i, (i != b) ? ' ' : '\n');
      }
    } else {
      if (0 <= a && a <= 5){
        DEPS(i, a, b){
          printf("%d%c", i, (i != b) ? ' ' : '\n');
        }
      } else {
        if (0 <= b && b <= 5){
          REPS(i, a, 10){
            printf("%d ", i);
          }
          DEPS(i, 5, b){
            printf("%d%c", i, (i != b) ? ' ' : '\n');
          }
        } else {
          REPS(i, a, 10){
            printf("%d ", i);
          }
          DEPS(i, 5, 1){
            printf("%d ", i);
          }
          REP(i, b + 1){
            printf("%d%c", i, (i != b) ? ' ' : '\n');
          }
        }
      }
    }
  }

  return (0);
}