#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>off){
            if(on>=6&&off>=6){
                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<<" ";
            }else{
                int cnt=on;
                while (1) {
                    if(cnt==off)break;
                    cout<<cnt<<" ";
                    cnt--;
                }
            }
        }else{
            for(int i=on;i<off;i++)cout<<i<<" ";
        }
        cout<<off<<endl;
    }
}
