#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    for (int j=0; j<n; j++) {
        int on,off;
        cin>>on>>off;
        if(on<6){
            if(on<off){
                for(int i=on;i<off;i++)cout<<i<<" ";
                cout<<off<<endl;
            }else{
                for(int i=on;i>off;i--)cout<<i<<" ";
                cout<<off<<endl;
            }
        }else{
            if(off>5){
                if(on<off){
                    for(int i=on;i<off;i++)cout<<i<<" ";
                    cout<<off<<endl;
                }else{
                    for(int i=on;i<10;i++)cout<<i<<" ";
                    for(int i=5;i>0;i--)cout<<i<<" ";
                    for(int i=0;i<off;i++)cout<<i<<" ";
                    cout<<off<<endl;
                }
            }else{
                for(int i=on;i<10;i++)cout<<i<<" ";
                for(int i=5;i>off;i--)cout<<i<<" ";
                cout<<off<<endl;
            }
        }
    }
}
