#include <cstdio>
#include <climits>
using namespace std;

int main()
{
	int n;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		int l_roote[16] = {a};
		int l = 0;
		if (a < 1 || a > 5){
			l = INT_MAX;
		}
		else {
			int p = a;
			int angle = -1;
			while (p != b){
				p += angle;
				
				if (p == -1){
					p = 1;
					angle = 1;
				}
				else if (p == 10){
					p = 5;
					angle = -1;
				}
				
				l_roote[++l] = p;
			}
		}
		
		int r_roote[16] = {a};
		int r = 0;
		
			int p = a;
			int angle = 1;
			while (p != b){
				p += angle;
				
				if (p == -1){
					p = 1;
					angle = 1;
				}
				else if (p == 10){
					p = 5;
					angle = -1;
				}
				
				r_roote[++r] = p;
			}
		
		if (l < r){
			for (int j = 0; j <= l; j++){
				if (j != 0){
					printf(" ");
				}
				printf("%d", l_roote[j]);
			}
		}
		else {
			for (int j = 0; j <= r; j++){
				if (j != 0){
					printf(" ");
				}
				printf("%d", r_roote[j]);
			}
		}
		puts("");
	}
	
	return 0;
}