#include <iostream>
#include <string>
using namespace std;

int main()
{
    char stop[] = 
    {'0','1','2','3','4','5','6','7','8','9','5','4','3','2','1'};
    
	int N;
	cin >> N;
	while(N--)
	{
		string ans;
	    char start,last;
	    cin >> start >> last;

	    bool started=false, end=false;
		while(1)
		{
		    for(int i=0; i<15; i++)
		    {
				if(started)
				{
		        	ans+=" ";
					ans+=stop[i]; 
				}
				
		        if(stop[i]==start)
		        {
					ans.clear();
					ans+=stop[i];
		            started = true;
		        }
		        	
		        if(stop[i]==last && started)
		        {
					end=true;
		            break;
		        }
		    }
			if(end) break;
		}

		cout << ans << endl;
	}
}