#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  const char *ans[10][10]={
    "","0 1","0 1 2","0 1 2 3","0 1 2 3 4","0 1 2 3 4 5","0 1 2 3 4 5 6","0 1 2 3 4 5 6 7","0 1 2 3 4 5 6 7 8","0 1 2 3 4 5 6 7 8 9",
    "1 0","","1 2","1 2 3","1 2 3 4","1 2 3 4 5","1 2 3 4 5 6","1 2 3 4 5 6 7","1 2 3 4 5 6 7 8","1 2 3 4 5 6 7 8 9",
    "2 1 0","2 1","","2 3","2 3 4","2 3 4 5","2 3 4 5 6","2 3 4 5 6 7","2 3 4 5 6 7 8","2 3 4 5 6 7 8 9",
    "3 2 1 0","3 2 1","3 2","","3 4","3 4 5","3 4 5 6","3 4 5 6 7","3 4 5 6 7 8","3 4 5 6 7 8 9",
    "4 3 2 1 0","4 3 2 1","4 3 2","4 3","","4 5","4 5 6","4 5 6 7","4 5 6 7 8","4 5 6 7 8 9",
    "5 6 7 8 9 5 4 3 2 1 0","5 6 7 8 9 5 4 3 2 1","5 6 7 8 9 5 4 3 2","5 6 7 8 9 5 4 3","5 6 7 8 9 5 4","","5 6","5 6 7","5 6 7 8","5 6 7 8 9",
    "6 7 8 9 5 4 3 2 1 0","6 7 8 9 5 4 3 2 1","6 7 8 9 5 4 3 2","6 7 8 9 5 4 3","6 7 8 9 5 4","6 7 8 9 5","","6 7","6 7 8","6 7 8 9",
    "7 8 9 5 4 3 2 1 0","7 8 9 5 4 3 2 1","7 8 9 5 4 3 2","7 8 9 5 4 3","7 8 9 5 4","7 8 9 5","7 8 9 5 4 3 2 1 0 1 2 3 4 5 6","","7 8","7 8 9",
    "8 9 5 4 3 2 1 0","8 9 5 4 3 2 1","8 9 5 4 3 2","8 9 5 4 3","8 9 5 4","8 9 5","8 9 5 4 3 2 1 0 1 2 3 4 5 6","8 9 5 4 3 2 1 0 1 2 3 4 5 6 7","","8 9",
    "9 5 4 3 2 1 0","9 5 4 3 2 1","9 5 4 3 2","9 5 4 3","9 5 4","9 5","9 5 4 3 2 1 0 1 2 3 4 5 6","9 5 4 3 2 1 0 1 2 3 4 5 6 7","9 5 4 3 2 1 0 1 2 3 4 5 6 7 8","",
  };
  int n;
  scanf("%d",&n);
  while(n --> 0){
    int a,b;
    scanf("%d%d",&a,&b);
    puts(ans[a][b]);
  }
  return 0;
}