#include<iostream>
using namespace std;

int m;

void solve(int n, bool d){
  
  if(n == m){
    cout << n << endl;
    return;
  }
  
  cout << n << " ";
  
  if(n == 9) solve(5, false);
  else if(!n || d) solve(n+1, true);
  else solve(n-1, false);
  
}

int main(){
  
  int n, l;

  cin >> l;
  
  while(l--){
    
    cin >> n >> m;
    
    if(n == 9 || (n < 6 && n > m)) solve(n, false);
    else solve(n, true);
        
  }
}