#include <cstdio>
#include <cstring>
char* bus="0123456789543210123456789";
char s[25], t[25];
int main()
{
    int n; scanf("%d", &n);
    while (n--) {
        int a, b; scanf("%d%d", &a, &b);
        int k = 0;
        for (int i = 0; i < 15; ++i)
            if (bus[i] == a + '0') k = i;
        int j = 0;
        for (int i = k; i < strlen(bus); ++i) {
            s[j++] = bus[i];
            s[j++] = ' ';
            if (bus[i] == b + '0') break;
        }
        if (s[j-2] != b + '0') for (j = 0; j < 25; ++j) s[j] = 'x';
        s[j-1] = '\0';

        k = 0;
        for (int i = 0; i < 15; ++i)
            if (bus[i] == a + '0') { k = i; break; }
        j = 0;
        for (int i = k; i < strlen(bus); ++i) {
            t[j++] = bus[i];
            t[j++] = ' ';
            if (bus[i] == b + '0') break;
        }
        if (t[j-2] != b + '0') for (j = 0; j < 25; ++j) t[j] = 'x';
        t[j-1] = '\0';
        puts(strlen(s) < strlen(t) ? s : t);
    }
    return 0;
}