#include<cstdio>

int n,m,l,k;

void solve(int p, int d){

  if(p == m){
    printf("%d\n",p);
    return;
  }

  printf("%d ", p);

  if(p == 9) solve(5, 0);
  else if(!p || d) solve(p+1, 1);
  else solve(p-1, 0);

}

int main(){

  scanf("%d", &l);

  while( l-- ){

    scanf("%d %d",&n, &m);

    if(n == 9 || (n < 6 && n > m)) k = 0;
    else k = 1;
    
    solve(n, k);

  }

}