CF1890B.Qingshan Loves Strings

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Qingshan Loves Strings

Qingshan has a string ss, while Daniel has a string tt. Both strings only contain 0 and 1.

A string aa of length kk is good if and only if

  • aiai+1a_i \ne a_{i+1} for all i=1,2,,k1i=1,2,\ldots,k-1.

For example, 1, 101, 0101 are good, while 11, 1001, 001100 are not good.

Qingshan wants to make ss good. To do this, she can do the following operation any number of times (possibly, zero):

  • insert tt to any position of ss (getting a new ss).

Please tell Qingshan if it is possible to make ss good.

Input

The input consists of multiple test cases. The first line contains a single integer TT (1T20001\le T\le 2000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and mm (1n,m501 \le n,m \le 50) — the length of the strings ss and tt, respectively.

The second line of each test case contains a string ss of length nn.

The third line of each test case contains a string tt of length mm.

It is guaranteed that ss and tt only contain 0 and 1.

Output

For each test case, print "YES" (without quotes), if it is possible to make ss good, and "NO" (without quotes) otherwise.

You can print letters in any case (upper or lower).

Note

In the first test case, ss is good initially, so you can get a good ss by doing zero operations.

In the second test case, you can do the following two operations (the inserted string tt is underlined):

  1. 1}\underline{\texttt{010}}\texttt{11
  2. 10101}\underline{\texttt{010}}\texttt{1

and get s=101010101s = \texttt{101010101}, which is good.

In the third test case, there is no way to make ss good after any number of operations.

Samples

5
1 1
1
0
3 3
111
010
3 2
111
00
6 7
101100
1010101
10 2
1001001000
10
Yes
Yes
No
No
No

在线编程 IDE

建议全屏模式获得最佳体验