409470: GYM103575 A Designing a New Logo

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Designing a New Logotime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

"Tinkoff" is rebranding! According to the latest trends, it was decided that the new logo is going to be in a checkered pattern. The new logo will be a shape made of $$$1 \times 1$$$ squares, such that any two squares that share a side are of different colors: one black and one white. The logo also has to be connected: it is possible to reach any square from any other, moving between the side-adjacent squares.

The brand book states that the logo must have exactly $$$w$$$ white squares and $$$b$$$ black squares. So that the logo doesn't look too dark or too bright, $$$b \le w \le 3b + 1$$$ must hold.

The brand team brought checkered pattern sheets to start printing new "Tinkoff" logos. Every sheet is a rectangle with $$$4n$$$ rows and $$$4m$$$ columns, the top left square of each sheet is black. You are tasked to cut the new logo out of them. Just to be sure, the brand team ordered the sheets of a large enough size: the number of black squares in the logo $$$b$$$ doesn't exceed $$$nm$$$.

Your task is to design a connected logo consisting of $$$b$$$ black and $$$w$$$ white squares such that it fits into the rectangular sheet of size $$$4n \times 4m$$$. The company analysts proved that on the sheet of size $$$4n \times 4m$$$, one can always make a logo provided that both $$$b \le w \le 3b + 1$$$ and $$$b \le nm$$$ hold.

Input

The input consists of several tests.

The first line contains an integer $$$t$$$ — the number of tests in the input ($$$1 \le t \le 2\,000$$$). Then, $$$t$$$ tests follow, each one on a separate line.

The test description consists of four integers $$$n$$$, $$$m$$$, $$$b$$$, $$$w$$$ ($$$1 \le n, m \le 50$$$; $$$0 \le b \le n \cdot m$$$; $$$b \le w \le 3b + 1$$$).

The total sum of $$$4n \cdot 4m$$$ of all tests in a single input doesn't exceed $$$2 \cdot 10^5$$$.

Output

Print the grid of size $$$4n \times 4m$$$ with the logo for each test. 'W' character stands for the white square, 'B' — for the black square, and '.' — for the square that doesn't belong to the logo.

Any connected logo with $$$w$$$ white squares and $$$b$$$ black squares will be accepted.

Scoring
SubtaskScoreConstraints
120$$$b = w$$$
225$$$b \le 2m - 1$$$
325$$$b \le 2(n + m) - 3$$$
430No additional constraint
ExampleInput
2
2 3 5 7
2 2 4 8
Output
............
..WBWBWBW...
.....W......
.....B......
.....W......
.....B......
.....W......
............
........
........
...W.W..
..WBWB..
...W.W..
..WBWB..
........
........

加入题单

算法标签: