#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int n;
    string s = "0123456789543210123456789543210123456789543210";
    cin >> n;
    for(int i=0;i<n;i++){
	char a,b;
	cin >> a >> b;
	int m = (int)(a - '0');
	int l = (int)(b - '0');
	if(0<= m && m  <= 5 && 0<= l && l <= 5){
	    if(m < l){
		cout << m;
		for(int i=m+1;i<=l;i++){
		    cout << " " << i;
		}
		cout << endl;
	    }else{
		cout << m;
		for(int i=m-1;i>=l;i--){
		    cout << " " << i;
		}
		cout << endl;
	    }
	    continue;
	}
	int x = 0;
	cout << a;
	while(s[x] != a) x++;
	while(s[x] != b){
	    x++;
	    cout << " "<< s[x];
	}
	cout << endl;

    }
    return 0;
}