#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  cin>>n;
  while(n--){
    int a,b;
    vector<int> ans;
    cin>>a>>b;
    bool rev=false;
    if(a>b){
      swap(a,b);
      rev = true;
    }
    if(a<5){
      for(int i=a; i<5&&i<=b;i++){
        ans.push_back(i);
      }
    }
    if(b>=5){
      if(b<=7){
        for(int i=5; i<=b; i++){
          ans.push_back(i);
        }
      }else{
        ans.push_back(5);
        for(int i=9; i>=b; i--){
          ans.push_back(i);
        }
      }
    }
    if(rev) reverse(ans.begin(),ans.end());
    REP(i,ans.size()){
      if(i) cout<<" ";
      cout<<ans[i];
    }
    cout<<endl;
  }
  return 0;
}