#include<bits/stdc++.h>
using namespace std;
string a="6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2";
main(){
  int n,s,t,i,j;
  cin>>n;
  while(n--){
    cin>>s>>t;
    for(i=0;s!=a[i]-'0';i++);
    for(j=i;t!=a[j]-'0';j++)if(a[j]-'0'==s)i=j;
    cout<<a.substr(i,j-i+1)<<endl;
  }
}