#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,a,b;

int main(){
	cin>>n;
	while(cin>>a>>b){
		if(a<=5||a>5&&b>a){
			if(a<b){
				for(int i=a;i<=b;i++){cout<<i;if(i!=b)cout<<" ";}
				cout<<endl;
			}
			else {
				for(int i=a;i>=b;i--){cout<<i;if(i!=b)cout<<" ";}
				cout<<endl;
			}
		}
		if(a>5&&b<=5){
			for(int i=a;i<=9;i++)cout<<i<<" ";
			for(int i=5;i>=b;i--){cout<<i;if(i!=b)cout<<" ";}
			cout<<endl;
		}
		if(a>5&&b>5&&b<a){
			for(int i=a;i<=9;i++)cout<<i<<" ";
			cout<<"5 4 3 2 1 0 1 2 3 4 5 ";
			for(int i=6;i<=b;i++){cout<<i;if(i!=b)cout<<" ";}
			cout<<endl;
		}
	}
}