#include<iostream>
using namespace std;

int main(void){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int f,t;
		scanf("%d%d",&f,&t);
		printf("%d",f);
		if(f<=5){
			if(t>f){
				while(f!=t){
					f++;
					printf(" %d",f);
				}
			}
			if(t<f){
				while(f!=t){
					f--;
					printf(" %d",f);
				}
			}
		}else if(f>5){
			if(f<t && t<=9){
				while(f!=t){
					f++;
					printf(" %d",f);
				}
			}else if(t==5){
				while(f!=9){
					f++;
					printf(" %d",f);
				}
				f=5;
				printf(" %d",f);
			}else{
				while(f!=9){
					f++;
					printf(" %d",f);
				}
				f=5;
				printf(" %d",f);
				if(t<5){
					while(f!=t){
						f--;
						printf(" %d",f);
					}
				}else{
					while(f!=0){
						f--;
						printf(" %d",f);
					}
					while(f!=t){
						f++;
						printf(" %d",f);
					}
				}
			}
		}
		printf("\n");
	}
    return 0;
}