OpenJudge

C17B:Tiling Dominoes

总时间限制:
1000ms
内存限制:
65536kB
描述

Is it possible to tile a chessboard of size N*M with dominoes of size 2*1, satisfying that each square is covered exactly once?

Foreseeable is such a smart guy to solve this problem. But what he really wants is a compact solution. A solution is called compact if and only if after Foreseeable tiles the chessboard like that, he cannot divide the chessboard into two rectangles without cutting off any piece of domino.

Can you find a compact solution for him?


输入
The first line contains an integer T (1 <= T <= 200), indicating the number of test cases.

For each test case:

One line contains two integers N and M (1 <= N,M <= 100), indicating the size of the chessboard.
输出
For each test case:

If there is no compact solution, output "impossible" on a single line;

If there are several compact solutions, output any one of them. Output N lines, each line contains a string of M upper case letters ("A" to "Z"), indicating the way to tile the chessboard with dominoes. Each domino is represented by two adjacent (sharing a common edge) squares with the same letter. You can mark each domino with any upper case letter, however, any two adjacent (sharing at least one common edge) dominoes should be marked with different letters.
样例输入
4
1 2
3 4
5 6
7 7
样例输出
AA
impossible
ABBABB
ACCADC
CDBBDC
CDACCA
BBABBA
impossible
全局题号
15047
添加于
2017-05-21
提交次数
110
尝试人数
14
通过人数
9