#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;

int main(){
	int n; cin>>n;
	vector<int> v;
	FOR(i,10) v.push_back(i);
	for(int i = 5; i > 0; i--) v.push_back(i);
	while(n--){
		int x,y; cin>>x>>y;
		int ans_l,a_cnt = 100;
		FOR(i,sz(v)){
			if(v[i] == x){
				int cnt = 1;
				for(int j = i+1; v[j] != y; j = (j+1) % sz(v))
					cnt++;
				if(a_cnt > cnt){
					a_cnt = cnt;
					ans_l = i;
				}
			}
		}

		for(int i = 0; i <= a_cnt; i++) printf("%d%c",v[(ans_l+i)%sz(v)],i==a_cnt?'\n':' ');
	}

	return 0;
}