#include <iostream>
using namespace std;

int main(){
    int ans2[20],ans1[20];
    int n,f,e,cnt;
    bool sj,fj,judge,ze,ro;
    cin >> n;
    while(n--){
        cin >> f >> e;
        cnt = 1;
        sj = false;
        fj = false;
        ze = true;
        ro = true;
        judge = false;
        int sta = f;
        ans1[0] = sta;
        ans2[0] = sta;
        while(1){
            if(sta == e) break;
            if(f == e){
                judge = true;
                break;
            }
            if(f > 5 && f < 9) f = -100000;
            if(sta == 9 && !sj){
                sta = 5;
                sj = true;
            }
            else if(sta == 0 && sj) sj = false;
            else if(sj) sta--;
            else if(!sj) sta++;
            ans1[cnt] = sta;
            
            if(f == 0 && !fj) fj = true;
            else if(f == 9 && !fj){
                fj = false;
                f = 5;
            }
            else if(!fj) f--;
            else if(fj) f++;
            ans2[cnt] = f;
            cnt++;
        }
        if(judge){
            for(int i=0;i<cnt-1;i++){
                cout << ans2[i] << " ";
                if(ans2[i+1] == 0 && ans2[i] == 0) i++;
            }
            cout << ans2[cnt-1] << endl;
        }
        else {
            for(int i=0;i<cnt-1;i++){
                cout << ans1[i] << " ";
                if(ans1[i+1] == 0 && ans1[i] == 0) i++;
            }
            cout << ans1[cnt-1] << endl;
        }
    }
}