#include <bits/stdc++.h>
#define//x方向进行移动
#define//y方向进行移动
using namespace std;
const int MAX_N = 27;
//字典序最小的方向增量
const int a[8] = {-1,1,-2,2,-2,2,-1,1}; //配合xa食用
const int b[8] = {-2,-2,-1,-1,1,1,2,2}; //配合yb食用
int vis[MAX_N][MAX_N]; //棋盘/访问记录数组
pair<char, char> way[MAX_N]; //合法路径记录数组
int n, p, q, cnt = 0, flag = 0;
void dfs(int x, int y, int dep)
{
way[dep].first = y + 'A' - 1, way[dep].second = x + '0';
if (dep == p * q)
{
flag = 1;
return;
}
for (int i = 0; i < 8; i++)
{
if (xa > 0 && xa <= p && yb > 0 && yb <= q && !vis[xa][yb] && !flag)
{
vis[xa][yb] = 1;
dfs(xa, yb, dep + 1);
vis[xa][yb] = 0; //回溯
}
}
}
int main()
{
cin >> n;
while(n--){
flag = 0, cnt++;
cin >> p >> q;
memset(vis, false, sizeof(vis));
vis[1][1] = true; //起点
dfs(1, 1, 1);
cout << "Scenario #" << cnt << endl;
if (flag)
{
for (int i = 1; i <= p * q; i++) cout << way[i].first << way[i].second;
cout << endl;
}
else cout << "impossible" << endl;
if(n != 0) cout << endl; //这里有坑
}
return 0;
}