2102: [USACO 2026 Second Contest, Bronze] Problem 1. It's Mooin' Time IV

文件提交:无需freopen 内存限制:256 MB 时间限制:2.000 S
评测方式:普通裁判 命题人:
提交:0 解决:0

题目描述

Bessie has a computer with a keyboard that only has two letters, M and O.

Bessie wants to type her favorite moo S consisting of N letters, each of which is either an M or an O. However, her computer has been hit with a virus. Every time she tries to type the letter O, every letter that she has typed so far flips, either from M to O or from O to M, before the O appears.

Is it possible for Bessie to type out her favorite moo?

Additionally, Bessie is given a parameter k which is either 0 or 1 .

  • If k=0 , then Bessie only needs to determine whether it is possible to type out her favorite moo.
  • If k=1 , then Bessie also needs to give an example of a sequence of keystrokes to type so she can type out her favorite moo.

输入

The first line contains T, the number of independent test cases (1 ≤ T ≤ 10^4) and k (0 ≤ k ≤ 1).

The first line of each test case has N (1 ≤ N ≤ 2 * 10^5).

The second line of each test case has S. 

It is guaranteed that no characters will appear in S besides M and O.

The sum of N across all test cases will not exceed 4 * 10^5.

输出

For each test case, output either one or two lines using the following procedure. If it is impossible for Bessie to type out S, print NO on a single line. 

Otherwise, on the first line print YES. 

Furthermore, if k=1 , on the second line, print a string of length N , the characters in order that Bessie needs to type in order to type out her favorite moo.

If there are multiple such strings, any will be accepted.

样例输入

2 0
3
MOO
5
OOMOO

样例输出

YES
YES

提示

SAMPLE INPUT

2 1

3

MOO

5

OOMOO


SAMPLE OUTPUT

YES

OMO

YES

MOOMO



As Bessie types out , this is how the letters change:

  1. Before typing the first , Bessie has an empty string. Afterwards, she has the string .
  2. After typing the first , the  flips to , and then the  is appended to form .
  3. After typing the second , the  flips to , and then the  is appended to form .
  4. After typing the second , Bessie has the string .
  5. After typing the last , the string  flips to , and then the  is appended to form , as desired.


SCORING:

  • Inputs 3-4: .
  • Inputs 5-6: .
  • Inputs 7-9: .
  • Inputs 10-16: .

来源/分类