#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;

int main(){
	int n;
	scanf("%d",&n);
	int a[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8};
	int b[] = {0,1,2,3,4,5};
	rep(q,n){
		int from,to;
		bool f = false;
		scanf("%d%d",&from,&to);
		if(from < 6 && to < 6){
			if(from > to){
				int x = from;
				while(1){
					if(b[x] == to){
						printf(" %d\n",to);
						break;
					}
					if(f)printf(" ");
					printf("%d",b[x]);
					x--;
					f = true;
				}
			}
			else{
				int x = from;
				while(1){
					if(b[x] == to){
						printf(" %d\n",to);
						break;
					}
					if(f)printf(" ");
					printf("%d",b[x]);
					x++;
					f = true;
				}
			}
		}
		else{
			int x = from;
			while(1){
				if(a[x] == to){
					printf(" %d\n",to);
					break;
				}
				if(f)printf(" ");
				printf("%d",a[x]);
				x++;
				f = true;
			}
		}
	}
	return 0;
}