聪明人才能看出端倪

D. Colorful Stamp

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A row of nn cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as BRBR and as RBRB.

During use, the stamp must completely fit on the given nn cells (it cannot be partially outside the cells). The stamp can be applied multiple times to the same cell. Each usage of the stamp recolors both cells that are under the stamp.

For example, one possible sequence of stamps to make the picture BRBBWBRBBW could be WWWWW→WWRB–––W→BR–––RBW→BRB–––BWWWWWW→WWRB_W→BR_RBW→BRB_BW. Here WW, RR, and BB represent a white, red, or blue cell, respectively, and the cells that the stamp is used on are marked with an underline.

Given a final picture, is it possible to make it using the stamp zero or more times?

Input

The first line contains an integer tt (1≤t≤1041≤t≤104) — the number of test cases.

The first line of each test case contains an integer nn (1≤n≤1051≤n≤105) — the length of the picture.

The second line of each test case contains a string ss — the picture you need to make. It is guaranteed that the length of ss is nn and that ss only consists of the characters WW, RR, and BB, representing a white, red, or blue cell, respectively.

It is guaranteed that the sum of nn over all test cases does not exceed 105105.

Output

Output tt lines, each of which contains the answer to the corresponding test case. As an answer, output "YES" if it possible to make the picture using the stamp zero or more times, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

Example

input

Copy

12
5
BRBBW
1
B
2
WB
2
RW
3
BRB
3
RBB
7
WWWWWWW
9
RBWBWRRBW
10
BRBRBRBRRB
12
BBBRWWRRRWBR
10
BRBRBRBRBW
5
RBWBW

output

Copy

YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO

Note

The first test case is explained in the statement.

For the second, third, and fourth test cases, it is not possible to stamp a single cell, so the answer is "NO".

For the fifth test case, you can use the stamp as follows: WWW→WRB–––→BR–––BWWW→WRB_→BR_B.

For the sixth test case, you can use the stamp as follows: WWW→WRB–––→RB–––BWWW→WRB_→RB_B.

For the seventh test case, you don't need to use the stamp at all.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值