#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	const int path1[] = { 0, 1, 2, 3, 4, 5, 4, 3, 2, 1 };
	const int path2[] = { 5, 6, 7, 8, 9 };

	int len1 = sizeof(path1)/sizeof (path1[0]);
	int len2 = sizeof(path2)/sizeof (path2[0]);

//	cut here before submit 
//	freopen ("testcase.busline2", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int i, j, k;
		for (i = 0; i < n; ++i){
			getline (cin, str );
			if (str.empty() ){
				break;
			} // end if
			vector <int> res;
			int from, to;
			stringstream ss(str);
			ss >> from >> to;

			if (from < to ){
				if (from < 5 && to <= 5 ){
					for (j = from; j <= to; ++j){
						res.push_back (path1[j]);
					} // end if
				}else if (from < 5 && to > 5){
					for (j = from; path1[j] != 5; ++j){
						res.push_back (path1[j]);
					} // end for
					for (k = 0; path2[k] <= to; ++k){
						res.push_back (path2[k]);
					} // end if
				}else if (from >= 5 && to > 5){
					for (k = from - 5; path2[k] <= to; ++k){
						res.push_back (path2[k]);
					} // end if
				} // end if
			}else if (from > to){
				if (from <= 5 && to < 5 ){
					for (j = (len1 - from) % len1; path1[j] != to; j = (j + 1) % len1){
						res.push_back (path1[j]);	
					} // end for
					res.push_back (path1[j] );
				}else if (from > 5 && to <= 5 ){
					for (k = from - 5; path2[k] != 5; k = (k + 1) % len2 ){
						res.push_back (path2[k]);
					} // end for
					for (j = 5; path1[j] != to; j = (j + 1) % len1 ){
						res.push_back (path1[j]);
					} // end for
					res.push_back (path1[j]);
				
				}else if (from > 5 && to > 5 ){
					for (k = from - 5; path2[k] != to; k = (k + 1) % len2 ){
						res.push_back (path2[k] );
					} // end for
					res.push_back (path2[k]);
				} // end if
			} // end if

			int size = res.size();
			for (j = 0; j < size; ++j){
				cout << res[j];
				if (j != size - 1){
					cout << ' ';
				} // end if
			} // end for
			cout << endl;
		} // end for
	} // end loop
		
	return 0;
}