#include <iostream>
#include <algorithm>
using namespace std;

int from, to;
int d[15] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
int p[2][15];

int calc(int pos, int k) {
  int cost = 0;
  p[k][0] = d[pos];
  while(d[pos] != to) {
    pos = (pos+1)%15;
    cost++;
    p[k][cost] = d[pos];
  }
  return cost;
}

void solve() {
  int k = 0;
  int mini = 999999;
  int mink = -1;
  for(int i = 0; i < 15; ++i) {
    if(d[i] == from) {
      int c1 = calc(i, k);
      if(c1 < mini) {
	mini = c1;
	mink = k;
      }
      k++;
    }
  }
  for(int i = 0; i <= mini; ++i) {
    if(i != 0) cout << " ";
    cout << p[mink][i];
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> from >> to;
    solve();
  }
}