#P1898C. Colorful Grid

    ID: 10207 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>constructive algorithms*1700

Colorful Grid

Description

Elena has a grid formed by nn horizontal lines and mm vertical lines. The horizontal lines are numbered by integers from 11 to nn from top to bottom. The vertical lines are numbered by integers from 11 to mm from left to right. For each xx and yy (1xn1 \leq x \leq n, 1ym1 \leq y \leq m), the notation (x,y)(x, y) denotes the point at the intersection of the xx-th horizontal line and yy-th vertical line.

Two points (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) are adjacent if and only if x1x2+y1y2=1|x_1-x_2| + |y_1-y_2| = 1.

The grid formed by n=4n=4 horizontal lines and m=5m=5 vertical lines.

Elena calls a sequence of points p1,p2,,pgp_1, p_2, \ldots, p_g of length gg a walk if and only if all the following conditions hold:

  • The first point p1p_1 in this sequence is (1,1)(1, 1).
  • The last point pgp_g in this sequence is (n,m)(n, m).
  • For each 1i<g1 \le i < g, the points pip_i and pi+1p_{i+1} are adjacent.

Note that the walk may contain the same point more than once. In particular, it may contain point (1,1)(1, 1) or (n,m)(n, m) multiple times.

There are n(m1)+(n1)mn(m-1)+(n-1)m segments connecting the adjacent points in Elena's grid. Elena wants to color each of these segments in blue or red color so that there exists a walk p1,p2,,pk+1p_1, p_2, \ldots, p_{k+1} of length k+1k+1 such that

  • out of kk segments connecting two consecutive points in this walk, no two consecutive segments have the same color (in other words, for each 1i<k1 \le i < k, the color of the segment between points pip_i and pi+1p_{i+1} differs from the color of the segment between points pi+1p_{i+1} and pi+2p_{i+2}).

Please find any such coloring or report that there is no such coloring.

Each test contains multiple test cases. The first line contains the number of test cases tt (1t321 \leq t \leq 32). The description of test cases follows.

The only line of each test case contains three integers nn, mm, and kk (3n,m163 \leq n,m \leq 16, 1k1091 \leq k \leq 10^9) — the dimensions of the grid and the number of segments in the walk Elena is looking for.

For each test case, output "NO" if it is not possible to color each of the n(m1)+(n1)mn(m-1)+(n-1)m segments in blue or red color, so that there exists a walk of length k+1k+1 satisfying the condition from the statement.

Otherwise, output in the first line "YES", and then provide the required coloring.

In each of the first nn lines of coloring description, output m1m-1 space-separated characters. The jj-th character in the ii-th of these nn lines should denote the color of the segment between points (i,j)(i,j) and (i,j+1)(i,j+1). Here, use 'B' to denote the blue color and 'R' to denote the red color.

In each of the next n1n-1 lines of coloring description, output mm space-separated characters. The jj-th character in the ii-th of these n1n-1 lines should denote the color of the segment between points (i,j)(i,j) and (i+1,j)(i+1,j). Similarly, use 'B' to denote the blue color and 'R' to denote the red color.

You can output each letter in the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses, and both 'R' and 'r' are valid notation of red.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t321 \leq t \leq 32). The description of test cases follows.

The only line of each test case contains three integers nn, mm, and kk (3n,m163 \leq n,m \leq 16, 1k1091 \leq k \leq 10^9) — the dimensions of the grid and the number of segments in the walk Elena is looking for.

Output

For each test case, output "NO" if it is not possible to color each of the n(m1)+(n1)mn(m-1)+(n-1)m segments in blue or red color, so that there exists a walk of length k+1k+1 satisfying the condition from the statement.

Otherwise, output in the first line "YES", and then provide the required coloring.

In each of the first nn lines of coloring description, output m1m-1 space-separated characters. The jj-th character in the ii-th of these nn lines should denote the color of the segment between points (i,j)(i,j) and (i,j+1)(i,j+1). Here, use 'B' to denote the blue color and 'R' to denote the red color.

In each of the next n1n-1 lines of coloring description, output mm space-separated characters. The jj-th character in the ii-th of these n1n-1 lines should denote the color of the segment between points (i,j)(i,j) and (i+1,j)(i+1,j). Similarly, use 'B' to denote the blue color and 'R' to denote the red color.

You can output each letter in the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses, and both 'R' and 'r' are valid notation of red.

Sample Input 1

5
4 5 11
3 3 2
3 4 1000000000
3 3 12588
4 4 8

Sample Output 1

YES
R R B B
R R R R
B B B R
R R B B
R B B R B
R B B B B
B B R R R
NO
NO
YES
R B
B B
B R
B B R
R B B
YES
B B R
R B R
B R R
R R B
B R R B
B B B B
B R R R

Note

In the first test case, one of the correct answers is shown in the picture below. The color-alternating walk of length 1212 is highlighted.

In the second and the third test cases, it can be shown that there is no coloring satisfying the condition from the statement.