#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	const int stations[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0};
	int n;
	scanf("%d", &n);
	rep(i, n){
		int s, g;
		scanf("%d%d", &s, &g);
		
		for(s = 5<s || s<g ? s : 15-s; stations[s] != stations[g]; ++s)
			printf("%d ", stations[s]);
		printf("%d\n", stations[g]);
	}
	return 0;
}