#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int n, p, q;
int used[26][26];
int pathX[26];
int pathY[26];
int dir[8][2] = { { -2, -1 }, { -2, 1 }, { -1, -2 }, { -1, 2 }, { 1, -2 }, { 1,
2 }, { 2, -1 }, { 2, 1 } };
int ok;
void dfs(int x, int y, int step) {
    pathX[step - 1] = x;
    pathY[step - 1] = y;
    used[x][y] = 1;
    if (step == p * q) {
        ok = 1;
        return;
    }
    int i;
    for (i = 0; i < 8; i++) {
        int _x = x + dir[i][0];
        int _y = y + dir[i][1];
        if (_x >= 0 && _y >= 0 && _x < p && _y < q && !used[_x][_y]) {
            dfs(_x, _y, step + 1);
        }
    }
    used[x][y] = 0;
}
int main() {
    int sum = 0;
    cin >> n;
    while (n--) {
        cin >> p >> q;
        ok = 0;
        memset(used, 0, sizeof(used));
        memset(pathX, 0, sizeof(pathX));
        memset(pathY, 0, sizeof(pathY));
        printf("Scenario #%d:\n", ++sum);
        dfs(0, 0, 1);
        if (ok != 1) {
            printf("impossible\n");
        } else {
            for (int i = 0; i < p * q; i++) {
                printf("%c%d", pathY[i] + 'A', pathX[i] + 1);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}