#include<iostream>
#include<vector>

//a->bまでangleの方向ではじめたときのルート
//angle: 1 -> right -1 -> left
std::vector<int> walk(int a, int b, int angle){
	std::vector<int> res;
	res.push_back(a);
	while(a != b){
		if(a == 9){
			a = 5;
			angle = -1;
		}else if(a == 0 && angle == -1){
			a = 1;
			angle = 1;
		}else{
			a += angle;
		}

		res.push_back(a);
	}
	
	return res;
}

int main(){
	int n, angle, a, b;
	std::cin >> n;
	for(;n--;){
		std::cin >> a >> b;

		std::vector<int> lv = walk(a, b, -1),
			rv = walk(a, b, 1), &shortest_v = lv;
		//a >= 6のとき左方向からはじめられない
		if(a >= 6 || lv.size() > rv.size()){
			shortest_v = rv;
		}

		std::cout << shortest_v[0];
		for(int i=1;i<shortest_v.size();i++){
			std::cout << " " << shortest_v[i];
		}
		std::cout << "\n";
	}
}