#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;

int main() {
  int T; cin >>T;
  REP(t, T){
    int a, b; cin >>a >>b;
    cout <<a;
    while(a != b){
      if(a <= 5) a = (abs(b - (a + 1)) < abs(b - (a - 1)) ? a + 1 : a - 1);
      else a += 1;
      if(a == 10) a = 5;
      if(a == -1) a = 1;
      cout <<" " <<a;
    }
    cout <<endl;
  }
  return 0;
}