#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const vector<int> bs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    int m = bs.size(), l = 0, r = 0;
    vector<int> p, q;
    while (l < m && bs[l] != a) l++, r++;
    while (r < m && bs[r] != b) p.emplace_back(bs[r++]);
    r = ++l;
    while (l < m && bs[l] != a) l++, r++;
    while (r < m && bs[r] != b) q.emplace_back(bs[r++]);
    if (int(p.size()) > int(q.size())) swap(p, q);
    for (int j = 0; j < int(p.size()); j++) {
      cout << p[j] << " ";
    }
    cout << b << endl;
  }  
  
  return 0;
}
