#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2 1";
int n, start, goal;
string ans;

int main(){
	cin >> n;
	REP(i, n){
		cin >> start >> goal;
		bool f = 0;
		int lb = 0, ub = 0;
		REP(i, s.size()){
			string t;
			if (s[i] - '0' == start){
				lb = i;
				f = 1;
			}
			if (f&&s[i] - '0' == goal){
				ub = i;
				//cout << lb << " " << ub << endl;
				t = s.substr(lb, ub - lb+1);
				if (ans.empty())ans = t;
				else{
					if (ans.size() > t.size())ans = t;
				}
			}
		}
		cout << ans << endl;
		ans.clear();
	}
}