#include <iostream>
using namespace std;

void solve(int f,int t) {
  bool r = false;
  if(f < t) {
    for(int i=0;i< t - f + 1;i++) {
      if(r) cout << " ";
      cout << f + i;
      r = true;
    }
    cout << endl;
    return;
  }

  else if(f > t) {
    if(f >= 6) {
      for(int i=0;i < 9 - f + 1;i++) {
        if(r) cout << " ";
        cout << f + i;
        r = true;
      }
      f = 5;
    }
    if(t == 5) {
      cout << 5 << endl;
      return;
    }
    for(int i=0;i< f - t + 1;i++) {
      if(r) cout << " ";
      cout << f - i;
      r = true;
    }
    cout << endl;
    return;
  }

  else if(f == t) {
    cout << f << endl;
    return;
  }
}

int main() {
  int n,f,t;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> f >> t;
    solve(f,t);
  }
}