#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int N = 10;
const int INF = 1e9;

vector<int> solve(int a, int b, int p){
  vector<int> res;
  res.push_back(a);
  while(a != b){
    a += p;
    if(a == 10) { a = 5; p = -1; }
    if(a == -1) { a = 1; p = 1; }
    res.push_back(a);
  }
  return res;
}

int main() {
  int T; cin >>T;
  REP(t, T){
    int a, b; cin >>a >>b;
    vector<int> ans = solve(a, b, 1);
    if(a <= 5){
      vector<int> tmp = min(ans, solve(a, b, -1));
      if(tmp.size() < ans.size()) ans = tmp;
    }
    REP(i, ans.size()) cout <<ans[i] <<(i + 1 == (int)ans.size() ? "" : " ");
    cout <<endl;
  }
  return 0;
}