#agc060b. [agc060_b]Unique XOR Path

[agc060_b]Unique XOR Path

Problem Statement

We have a grid with NN rows and MM columns. You want to write an integer between 00 and 2K12^K-1 in each square in the grid to satisfy the following condition.

  • Consider a path that starts at the top-left square, repeatedly moves right or down to an adjacent square, and ends at the bottom-right square. Such a path is said to be good if and only if the total mathrmXOR\\mathrm{XOR} of the integers written on the squares visited (including the starting and ending points) is 00.
  • There is exactly one good path, which is the path represented by a string SS. The path represented by the string SS is a path that, for each ii (1leqileqN+M21 \\leq i \\leq N+M-2), the ii-th move is right if the ii-th character of SS is R and down if that character is D.

Determine whether there is a way to write integers that satisfies the condition.

For each input file, solve TT test cases.

What is bitwise mathrmXOR\\mathrm{XOR}?

The bitwise mathrmXOR\\mathrm{XOR} of non-negative integers AA and BB, AoplusBA \\oplus B, is defined as follows.

  • When AoplusBA \\oplus B is written in binary, the kk-th lowest bit (kgeq0k \\geq 0) is 11 if exactly one of the kk-th lowest bits of AA and BB is 11, and 00 otherwise.

For instance, 3oplus5=63 \\oplus 5 = 6 (in binary: 011oplus101=110011 \\oplus 101 = 110).
Generally, the bitwise mathrmXOR\\mathrm{XOR} of kk non-negative integers p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k is defined as $(\\dots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\dots \\oplus p_k)$, which can be proved to be independent of the order of p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k.

Constraints

  • 1leqTleq1001 \\leq T \\leq 100
  • 2leqN,Mleq302 \\leq N,M \\leq 30
  • 1leqKleq301 \\leq K \\leq 30
  • SS is a string containing exactly N1N-1 Ds and M1M-1 Rs.
  • All numbers in the input are integers.

Input

The input is given from Standard Input in the following format:

TT case1case_1 case2case_2 vdots\\vdots caseTcase_T

Each case is in the following format:

NN MM KK SS

Output

For each case, print Yes if there is a way to write integers that satisfies the condition, and No otherwise. Each character in the output may be either uppercase or lowercase.


Sample Input 1

4
2 2 1
RD
4 3 1
RDDDR
15 20 18
DDRRRRRRRDDDDRRDDRDRRRRDDRDRDDRRR
20 15 7
DRRDDDDDRDDDRRDDRRRDRRRDDDDDRRRDD

Sample Output 1

Yes
No
Yes
No

As an example, for the first case, you can make the grid as follows.

11
00