#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 path[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
//	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;
			int len = sizeof(path)/sizeof(path[0]);
			if (from < to ){
				for (j = from; j != to; j = (j + 1) % len ){
					res.push_back(path[j]);
				} // end for
			}else if (from > to ){
				bool found = (from < 6 ? false : true);
				for (k = 0; k < len; ++k){
					if (path[k] == from){
						if (!found ){
							found = true;
							continue;
						}else{
							break;
						} // end if
					} // end if
				} // end for
				for (j = k; j != to || path[j] != to; j = (j + 1) % len ){
					res.push_back(path[j]);
				} // end for
			} // end if
						
			res.push_back(path[to] );

			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;
}