#include<cstdio>
using namespace std;

int n,m,l;

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)) solve(n, 0);
    else solve(n, 1);
  }
  
}