#include<bits/stdc++.h>
using namespace std;


int A[15]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

int ans[10][10];
int tmp[10][10];

int main(){
  for(int i=15;i>=0;i--){

    for(int a=0;a<15;a++){

      int from=A[a];
      int to=A[ (a+i)%15 ];
      
      ans[ from ][ to ]=i;
      tmp[ from ][ to ]=a;
    }
  }

  int tc;
  cin>>tc;

  for(int Tc=0;Tc<tc;Tc++){

    int from;
    int to;
    cin>>from>>to;

    for(int i=0;i<=ans[from][to];i++){
      if(i>0)cout<<' ';

      cout<< A[ (tmp[from][to]+i)%15 ];
    }
    cout<<endl;
    
  }
  
  return 0;
}

