#include<iostream>
#include<stack>
using namespace std;

int main(){

  int n,m,p,i;

  cin >> p;

  for(int s=0;s<p;s++){

    cin >> n >> m;
    i = n;

    cout << n;
    while(i != m){
      if(i == 9) i = 5;

      if(i > 5) i++;
      else if(i < m)i++;
      else if(i > m)i--;
      cout << " " << i;
    }

    cout << endl;
  }
}