题目描述
Problem Description
There are $ N $ grids. The size of the $i\ (1\ \leq\ i\ \leq\ N)$th grid is $ H_i $ rows and $ W_i $ columns. For each of the $ N $ grids, fill each cell with either A, B, or C such that the following conditions are met:
- The number of pairs of adjacent cells with one
Aand the otherB=
The number of pairs of adjacent cells with oneBand the otherC=
The number of pairs of adjacent cells with oneCand the otherA - Each row and each column of the grid contains at least one
A, oneB, and oneC.
Two cells on the grid are considered adjacent if they share a vertex or an edge.
It can be proven that within the constraints of this problem, there always exists a way to fill the grids to satisfy the conditions.
Input Format
The input is given from the standard input in the following format:
$ N $ $ H_1 $ $ W_1 $ $ H_2 $ $ W_2 $ $\vdots$ $ H_N $ $ W_N $
Output Format
For each $i\ (1\ \leq\ i\ \leq\ N)$, output a grid of size $ H_i $ rows and $ W_i $ columns that satisfies the conditions. Here, $S^i_{yx}\ (1\ \leq\ y\ \leq\ H_i,\ 1\ \leq\ x\ \leq\ W_i)$ is the character to be written in the $ y $th row and $ x $th column of the $ i $th grid, which can be A, B, or C.
$ S^1_{11}S^1_{12}...S^1_{1W_1} $ $ S^1_{21}S^1_{22}...S^1_{2W_1} $ $\vdots$ $ S^1_{H_11}S^1_{H_12}...S^1_{H_1W_1} $ $\vdots$ $ S^N_{11}S^N_{12}...S^N_{1W_N} $ $ S^N_{21}S^N_{22}...S^N_{2W_N} $ $\vdots$ $ S^N_{H_N1}S^N_{H_N2}...S^N_{H_NW_N} $
Sample Input and Output
Sample Input #1
1
4 4
Sample Output #1
ABCC
CACB
BCAA
CABA
Sample Input #2
2
4 5
5 4
Sample Output #2
CACCB
CBBAA
ACABC
BACBB
BCBA
CAAB
AACB
ABCC
BBCA
Notes/Hints
Constraints
- $1\ \leq\ N\ \leq\ 1,000$
- $4\ \leq\ H_i\ \leq\ 1,000$
- $4\ \leq\ W_i\ \leq\ 1,000$
- $\sum_{i=1}^{N}\ H_i\ \times\ W_i\ \leq\ 10^6$
- All inputs are integers.
Sample Explanation 1
The figure below shows the output example #1, with adjacent pairs of cells with A and B, B and C, C and A marked with red, green, and blue lines, respectively. There are 10 lines of each color, and each row and column contains at least one A, one B, and one C, so this output satisfies the conditions.  Adjacent cells in output example #1
Sample Explanation 2
The 4-row 5-column grid and the 5-row 4-column grid being output each satisfy the conditions.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分