#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define PB push_back
#define p(a,b) g.PB(pii(a, b))
#define INF (1<<29)

typedef pair<int, int> pii;
typedef vector<pii> vp;

int main() {
	vp g; //pos to
	REP(i, 9) p(i, i + 1);
	p(9, 10);
	REP(i, 4) p(5 - i, i + 11);
	p(1, 0);
	
	int n;
	cin >> n;
	while (n--) {
		int prev[2][20], miner[2], tmp[2];
		int a, b;
		scanf("%d %d", &a, &b);
		
		tmp[0] = tmp[1] = INF;
		REP(i, g.size()) if (g[i].first == a) {
			if (tmp[0] == INF) tmp[0] = i;
			else tmp[1] = i;
		}
		
		miner[0] = miner[1] = INF;
		REP(i, 2) {
			if (tmp[i] == INF) break;
			
			queue<int> que; //pos
			que.push(tmp[i]);
			
			miner[i] = 0;
			while(true) {
				int pos = g[que.front()].first;
				int to = g[que.front()].second;
				que.pop();
				
				prev[i][miner[i]++] = pos;
				if (pos == b) break;
				
				que.push(to);
			}
		}
		
		int ans = miner[0] < miner[1] ? 0 : 1;
		REP(i, miner[ans]) {
			if (i != 0) printf(" ");
			printf("%d", prev[ans][i]);
		}
		cout << endl;
	}
	return 0;
}