#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

#define N 15
int d[N] = {0, 1, 2, 3, 4, 5 ,6 ,7 ,8 ,9 ,5 ,4 ,3 ,2 ,1};

int main(void){
  int n ;
  cin>>n;
  while(n--){
    int a,b;
    cin>>a>>b;
    if(a<=5 && b < a){
      a = 15 - a;
    }
    while(d[a] != b){
      cout<<d[a]<<" ";
      a = (a + 1) % N; 
    }
    cout<<d[a]<<endl;
  }
}