#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cctype>
#include <sstream>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for (iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n) {
    while(n--) {
      int s,t;
      cin >> s >> t;
      vector<int> a;
      if(s<=5) {
	if(s<=t) {
	  while(s<=t) a.push_back(s++);
	} else {
	  while(s>=t) a.push_back(s--);
	}
      } else {
	if(t>=6 && s>t) {
	  while(s!=0) {
	    a.pb(s);
	    if(s>=6 && s<=9) s++;
	    else s--;
	    if(s==10) s=5;
	  }
	  while(s<=t) a.push_back(s++);	  
	} else {
	  while(1) {
	    a.pb(s);
	    if(s==t) break;
	    if(s>=6 && s<=9) s++;
	    else s--;
	    if(s==10) s=5;
	  }
	}
      }
      rep(i,a.size()) {
	if(i!=0) cout << " ";
	cout << a[i];
      }
      cout << endl;
    }
  }
  return 0;
}
