#include <iostream>
using namespace std;

char stop[] ="0123456789543210123456789";

void solve(int start,int goal) {
  int ans = 10000;int pos = 0;
  for(int i=0;i<25;i++) {
    if(stop[i] != start + '0') continue;
    //stop[i] == goal
    for(int j=i+1;j<25;j++) {
      if(stop[j] == goal + '0') {
        ans = min(ans,j-i);pos = i;
        continue;
      }
    }
  }
  for(int i = pos;i<=pos + ans;i++) {
    cout << ( i==pos ? "":" ") << stop[i];
  }
  cout << endl;
}

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