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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

signed main() {
	int n;
	cin >> n;

	while ( n-- ) {
		int a, b;
		cin >> a >> b;
		bool flag = a < b;
		while ( a != b ) {
			cout << a << " ";
			if ( flag ) {
				if ( a == 9 ) {
					a = 5;
					flag = false;
				}
				else a++;
			} else {
				if ( a == 0 ) {
					a = 1;
					flag = true;
				} else if ( a == 9 ) {
					a = 5;
				} else {
					a--;
				}
			}
		}
		cout << b << endl;
	}
	return 0;
}

