#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;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0ZGlvLmg+CiNpbmNsdWRlPHN0cmluZy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbiwgcCwgcTsKaW50IHVzZWRbMjZdWzI2XTsKaW50IHBhdGhYWzI2XTsKaW50IHBhdGhZWzI2XTsKaW50IGRpcls4XVsyXSA9IHsgeyAtMiwgLTEgfSwgeyAtMiwgMSB9LCB7IC0xLCAtMiB9LCB7IC0xLCAyIH0sIHsgMSwgLTIgfSwgeyAxLAoyIH0sIHsgMiwgLTEgfSwgeyAyLCAxIH0gfTsKaW50IG9rOwp2b2lkIGRmcyhpbnQgeCwgaW50IHksIGludCBzdGVwKSB7CiAgICBwYXRoWFtzdGVwIC0gMV0gPSB4OwogICAgcGF0aFlbc3RlcCAtIDFdID0geTsKICAgIHVzZWRbeF1beV0gPSAxOwogICAgaWYgKHN0ZXAgPT0gcCAqIHEpIHsKICAgICAgICBvayA9IDE7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgaW50IGk7CiAgICBmb3IgKGkgPSAwOyBpIDwgODsgaSsrKSB7CiAgICAgICAgaW50IF94ID0geCArIGRpcltpXVswXTsKICAgICAgICBpbnQgX3kgPSB5ICsgZGlyW2ldWzFdOwogICAgICAgIGlmIChfeCA+PSAwICYmIF95ID49IDAgJiYgX3ggPCBwICYmIF95IDwgcSAmJiAhdXNlZFtfeF1bX3ldKSB7CiAgICAgICAgICAgIGRmcyhfeCwgX3ksIHN0ZXAgKyAxKTsKICAgICAgICB9CiAgICB9CiAgICB1c2VkW3hdW3ldID0gMDsKfQppbnQgbWFpbigpIHsKICAgIGludCBzdW0gPSAwOwogICAgY2luID4+IG47CiAgICB3aGlsZSAobi0tKSB7CiAgICAgICAgY2luID4+IHAgPj4gcTsKICAgICAgICBvayA9IDA7CiAgICAgICAgbWVtc2V0KHVzZWQsIDAsIHNpemVvZih1c2VkKSk7CiAgICAgICAgbWVtc2V0KHBhdGhYLCAwLCBzaXplb2YocGF0aFgpKTsKICAgICAgICBtZW1zZXQocGF0aFksIDAsIHNpemVvZihwYXRoWSkpOwogICAgICAgIHByaW50ZigiU2NlbmFyaW8gIyVkOlxuIiwgKytzdW0pOwogICAgICAgIGRmcygwLCAwLCAxKTsKICAgICAgICBpZiAob2sgIT0gMSkgewogICAgICAgICAgICBwcmludGYoImltcG9zc2libGVcbiIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcCAqIHE7IGkrKykgewogICAgICAgICAgICAgICAgcHJpbnRmKCIlYyVkIiwgcGF0aFlbaV0gKyAnQScsIHBhdGhYW2ldICsgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==