#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>



using namespace std;

int basutei[15]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

int main(){
    int n;
    cin>>n;
    for(int roop=0; roop<n; roop++){
        int b,e;
        cin>>b>>e;
        int start1;
        int end1;
        for(int i=0; i<15; i++){
            if(basutei[i]==b){
                start1=i;
                break;
            }
        }
        
        for(int i=0; i<15; i++){
            if(basutei[(start1+i)%15]==e){
                end1=(start1+i)%15;
                break;
            }
        }
        int l1=0;
        if(end1<start1){
            l1=end1+15-start1;
        }else{
            l1=end1-start1;
        }
        
        //----------------------------------
        
        int start2;
        int end2;
        for(int i=15; i>=0; i--){
            if(basutei[i]==b){
                start2=i;
                break;
            }
        }
        
        for(int i=0; i<15; i++){
            if(basutei[(start2+i)%15]==e){
                end2=(start2+i)%15;
                break;
            }
        }
        
        int l2=0;
        if(end2<start2){
            l2=end2+15-start2;
        }else{
            l2=end2-start2;
        }
        if(l1<l2){
            cout<<basutei[start1];
            for(int i=start1+1; i<=start1+l1; i++){
                cout<<" "<<basutei[i%15];
            }
            cout<<endl;
        }else{
            cout<<basutei[start2];
            for(int i=start2+1; i<=start2+l2; i++){
                cout<<" "<<basutei[i%15];
            }
            cout<<endl;
            
        }
    }
}