#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,a,b;
	string str="54321012345678";
	cin>>n;
	rep(x,0,n){
		string ans="";
		cin>>a>>b;
		if(a<b){
			rep(i,a,b+1){
				if(ans!="") ans+=" ";
				ans=ans+(char)('0'+i);
			}
		}else if(a<=5){
			repb(i,a,b){
				if(ans!="") ans+=" ";
				ans=ans+(char)('0'+i);
			}
		}else{
			rep(i,a,10){
				if(ans!="") ans+=" ";
				ans=ans+(char)('0'+i);
			}
			rep(i,0,str.size()){
				if(ans!="") ans+=" ";
				ans=ans+str[i];
				if(str[i]==('0'+b)) break;
			}
		}
		cout<<ans<<endl;
	}
}