#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	string A = "012345678954321012345678954321";
	int n; cin >> n;
	rep(i,0,n){
		int a, b; cin >> a >> b;
		string ans = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
		rep(i, 0, A.size() / 2) {
			if (A[i] - '0' != a) continue;
			string temp = "";
			temp += A[i];
			rep(j, i + 1, A.size()) {
				temp += " ";
				temp += A[j];
				if (A[j] - '0' == b) break;
			}
			if (temp.size() < ans.size())ans = temp;
		}
		cout << ans << endl;
	}
	return 0;
}