#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

void f(int a,int b){
	cout<<a;
	if(a==b){cout<<endl;return;}
	if(6<=a&&a<=8){
		a++;
	}else if(a==9){
		a=5;
	}else if(a<b){
		a++;
	}else{
		a--;
	}
	cout<<" ";
	f(a,b);
}

int main() {
	int n=in();
	int a,b;
	int i;
	for(i=0;i<n;i++){
		cin>>a>>b;
		if(6<=b&&b<a){
			if(b==6&&a==7)cout<<"7 8 9 5 4 3 2 1 0 1 2 3 4 5 6"<<endl;
			if(b==6&&a==8)cout<<"8 9 5 4 3 2 1 0 1 2 3 4 5 6"<<endl;
			if(b==6&&a==9)cout<<"9 5 4 3 2 1 0 1 2 3 4 5 6"<<endl;
			if(b==7&&a==8)cout<<"8 9 5 4 3 2 1 0 1 2 3 4 5 6 7"<<endl;
			if(b==7&&a==9)cout<<"9 5 4 3 2 1 0 1 2 3 4 5 6 7"<<endl;
			if(b==8&&a==9)cout<<"9 5 4 3 2 1 0 1 2 3 4 5 6 7 8"<<endl;
		}else{
			f(a,b);
		}
	}
	return 0;
}