#include<iostream>
using namespace std;

void solve(int n, int m, bool d){

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

int main(){

  int l;
  int n,m;

  cin >> l;

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

}