#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void solve(Graph& g,int begin,int end)
{
	int size=g.size();
	vi prev(size,-1);
	queue<Edge> q;
	q.push(Edge(-2,begin));
	while(q.size()){
		Edge e=q.front(); q.pop();
		if(prev[e.dst]!=-1) continue;
		prev[e.dst]=e.src;
		foreach(it,g[e.dst])
			q.push(*it);
	}
	vi res;
	for(int i=end;i>=0;i=prev[i])
		res.push_back(i);
	reverse(allof(res));
	rep(i,res.size())
		printf("%d%c",res[i],i==res.size()-1?'\n':' ');
}

int main()
{
	Graph g(10);
	int src[]={0,1,1,2,2,3,3,4,4,5,5,6,7,8,9};
	int dst[]={1,0,2,1,3,2,4,3,5,4,6,7,8,9,5};
	rep(i,sizeof(src)/sizeof(src[0]))
		g[src[i]].push_back(Edge(src[i],dst[i]));
	
	int n;
	cin>>n;
	rep(i,n){
		int begin,end;
		cin>>begin>>end;
		solve(g,begin,end);
	}
	
	return 0;
}