
import std.stdio, std.range;

alias int function (int) Op;

Op decr, incr;

static this() {
  decr = (x) => x - 1;
  incr = (x) => x + 1;
}

void main() {
  int times;
  readf("%d\n", &times);
  foreach(t; 0..times) {
    int curr, finish;
    Op op;
    readf("%d %d\n", &curr, &finish);
    if (finish < curr && curr < 6) op = decr;
    else op = incr;
    do {
      if (curr > 9) {curr -= 5; op = decr;}
      write(curr, " ");
      curr = op(curr);
    } while(curr != finish);
    writeln(curr);
  }
}