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

int c[15] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

int main() {
  int n, a, b;
  cin >> n;
  while(n--) {
    cin >> a >> b;
    int res = 100;
    int minI, minJ;
    for(int i = 0; i < 15; ++i) {
      for(int j = 0; j < 15; ++j) {
        if(c[i] == a && c[j] == b) {
          int next = (j-i+15)%15;
          if(res > next) {
            res = next;
            minI = i;
            minJ = j;
          }
        }
      }
    }
    for(int k = minI; k != minJ; k = (k+1)%15) {
      cout << c[k] << " ";
    }
    cout << c[minJ] << endl;
  }
  return 0;
}