#include <iostream>

int main()
{
	int n; std::cin >> n;
	for (int i=0; i<n; i++) {
		int s, t;
		std::cin >> s >> t;
		std::cout << s;
		if (0 <= s && s <= 5) {
			if (0 <= t && t <= 5) {
				if (s<t) {
					for (int k=s+1; k<=t; k++) std::cout << " " << k;
				} else {
					for (int k=s-1; k>=t; k--) std::cout << " " << k;
				}
			}
			else { // t = 6,7,8,9
				for (int k=s+1; k<=t; k++) std::cout << " " << k;
				//for (int k=s+1; k<=5; k++) std::cout << " " << k;
				//if (t<=7) {
				//	for (int k=6; k<=t; k++) std::cout << " " << k;
				//} else {
				//	for (int k=9; k>=t; k--) std::cout << " " << k;
				//}
			}
		}
		else { // s = 6,7,8,9
			if (0 <= t && t <= 5) {
				//if (s <= 7) {
				//	for (int k=s-1; k>=t; k--) std::cout << " " << k;
				//} else {
					for (int k=s+1; k<=9; k++) std::cout << " " << k;
					for (int k=5; k>=t; k--) std::cout << " " << k;
				//}
			}
			else { // t = 6,7,8,9
				if (s<t) {
					for (int k=s+1; k<=t; k++) std::cout << " " << k;
				} else {
				//	for (int k=s-1; k>=t; k--) std::cout << " " << k;
					for (int k=s+1; k<=9; k++) std::cout << " " << k;
					for (int k=5; k>=0; k--) std::cout << " " << k;
					for (int k=1; k<=5; k++) std::cout << " " << k;
					for (int k=6; k<=t; k++) std::cout << " " << k;
				}
				
			}
		}
		std::cout << std::endl;
	}
	
	return 0;
}


