#include <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

void upto(vector<int>& v, int f, int t)
{
  for (int i = f; i <= t; i++) v.push_back(i);
}
void downto(vector<int>& v, int f, int t)
{
  for (int i = f; i >= t; i--) v.push_back(i);
}

int main()
{
  rep(i, in()){
    int f, t;
    f = in();
    t = in();
    vector<int> way;
    if (f < t) upto(way, f, t);
    else if (f <= 5) downto(way, f, t);
    else if (t <= 5) upto(way, f, 9), downto(way, 5, t);
    else upto(way, f, 9), downto(way, 5, 0), upto(way, 1, t);
    show(way, ' ');
  }
  return 0;
}