#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int bus[]{ 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0 };
int main() {
	int n; scanf("%d", &n);
	rep(t, n) {
		int s, g; scanf("%d%d", &s, &g);
		int x = 0, y = 31;
		for (int i = 0; i < 31; i++) {
			for (int j = i + 1; j < 31; j++) {
				if (bus[i] == s&&bus[j] == g&&j - i < y - x) {
					x = i; y = j;
				}
			}
		}
		for (int i = x; i <= y; i++) {
			printf("%d", bus[i]);
			if (i == y)printf("\n");
			else printf(" ");
		}
	}
}