#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  char s[]="012345678954321012345678";
 int len=24;
  int n;
  cin >>n;
  while(n--){
        int start,goal; cin>>start>>goal;
        int ans=100,ans_st;
        for(int i=0;i<len;i++){
            if(s[i]!=start+'0') continue;
            for(int j=i+1;j<len;j++){
                if(s[j]==goal+'0'){
		  if(ans>j-i)
		  ans=j;
		  ans_st=i;
                }
            }
        }
	cout <<s[ans_st];
	cout <<" ";
	for(int i =ans_st+1;i <ans;i++){
	  cout <<s[i]<<" ";
	}
	cout <<s[ans];
	cout <<endl;
  }
  return 0;
}