Fillomino
시간 제한1초메모리 제한1024 MB
토러스 모양 n×m 격자를 주어진 크기의 연결된 세 영역으로 나누되 각 아들의 칸을 포함하도록 하고, 불가능하면 -1을 출력한다.
문제
Prof. Pang is the king of Pangland. Pangland is a board with size . The cell at the -th row and the -th column is denoted as cell for all . If two cells share an edge, they are connected. The board is toroidal, that is, cell is also connected to and is also connected to for all .
Prof. Pang has three sons. We call them the first son, the second son and the third son. Each of them lives in a cell in Pangland. The -th son lives in cell . No two sons live in the same cell. Prof. Pang wants to distribute the cells in Pangland to his sons such that
- Each cell belongs to exactly one son.
- There are cells that belong to the -th son for all .
- The cells that belong to the -th son are connected for all .
- The cell that the -th son lives in must belong to the -th son himself for all .
Please help Prof. Pang to find a solution if possible.
입력
The first line contains a single integer () denoting the number of test cases.
For each test case, the first line contains two integers () separated by a single space.
The next line contains three positive integers () separated by single spaces.
The -th line of the next lines contains two integers () separated by a single space.
It is guaranteed that , , are distinct.
It is guaranteed that the sum of over all test cases is no more than .
출력
For each test case, if there is no solution, output "-1" in one line. Otherwise, output lines. Each line should contain characters. The -th character in the -th line should be 'A' if cell belongs to the first son, 'B' if cell belongs to the second son and 'C' if cell belongs to the third son. Cell must belong to the -th son for all . The cells that belong to the -th son must be connected for all .