#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a>>b;
        if (a<b) {
            for (int j=a;j<b+1;j++) {
                if (j==b) {
                    cout<<j<<endl;
                } else {
                    cout<<j<<" ";
                }
            }
        } else {    //a>b
            if (a<=5&&b<=5) {
                for (int k=a;k>=b;k--) {
                    if (k==b) {
                        cout<<k<<endl;
                    } else {
                        cout<<k<<" ";
                    }
                }
            } else if (b<=5) {
                for (int l=a;l<=9;l++) {
                    cout<<l<<" ";
                }
                for (int m=5;m>=b;m--) {
                    if (m==b) {
                        cout<<m<<endl;
                    } else {
                        cout<<m<<" ";
                    }
                }
            } else {
                for (int p=a;p<=9;p++) {
                    cout<<p<<" ";
                }
                for (int q=5;q>=0;q--) {
                    cout<<q<<" ";
                }
                for (int r=1;r<=b;r++) {
                    if (r==b) {
                        cout<<r<<endl;
                    } else {
                        cout<<r<<" ";
                    }
                }
            }
        }
    }
}
