#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem0140 : Bus Line **/
int main()
{
	int N; cin>>N;
	int p1[] = {6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0};
	
	rep(z, N) {
		int s, t; cin>>s>>t;
		
		int ans=INF, a=-1, b=-1;
		for (int i=0; i<25; i++) {
			if (p1[i]==s) {
				int tt=1;
				for (int j=i; j<25; j++) {
					if (p1[j]==t) {
						if (ans>tt) {
							ans = tt;
							a = i;
							b = i+tt;
						}
						break;
					}
					tt++;
				}
			}
		}
		
		
		for (int i=a; i<b; i++) {
			if (i!=a) cout<<" ";
			cout << p1[i];
		}
		cout << endl;
	}
}