#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,f,t,*ip,*p,*q,x,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,};
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d",&f,&t);
		q=&a[24];
		ip=&a[f];

		p=find(&a[f],a+24,t);
		if(f<6) q=find(a+10,a+24,t);

		if(q!=a+24)
		{
			if( q>a+15-f && (q-(a+15-f)) < (p-ip)) 
				ip=a+15-f, p=q;
		}
		x=0;
		for(;ip<=p;++ip)
			printf("%s%d",(x++?" ":""),*ip);
		putchar('\n');
	}
	return 0;
}