#include<iostream>
using namespace std;
int a[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int s,t;cin>>s>>t;
		int cnt=0,i=0;
		while(a[i]!=s)i++;
		while(a[(i+cnt)%15]!=t)cnt++;
		int cnta=1e5,j=i+1;
		while(j<15&&a[j]!=s)j++;
		if(j<15)
		{
			cnta=0;
			while(a[(j+cnta)%15]!=t)cnta++;
		}
		if(cnt<cnta)
		{
			for(int k=0;k<=cnt;k++)cout<<a[(i+k)%15]<<(k==cnt?"\n":" ");
		}
		else
		{
			for(int k=0;k<=cnta;k++)cout<<a[(j+k)%15]<<(k==cnta?"\n":" ");
		}
	}
}

