|
The 2019 Hacker Cup Finals have just concluded! There were **N** participants |
|
(numbered 1 to **N**), including yourself (competing as participant 1), and |
|
**M** problems (numbered 1 to **M**). |
|
|
|
Participant _i_ solved problem _j_ if **Si,j** = "Y", and otherwise they |
|
didn't solve it (if **Si,j** = "N"). Problem _i_'s point value is 2i, and each |
|
participant's score is the sum of the point values of the problems that they |
|
solved. No two participants solved exactly the same set of problems, which |
|
also means that all participants have distinct scores. |
|
|
|
Before the final results get announced, you have an opportunity to rearrange |
|
the **M** columns of the scoreboard **S** into any permutation of problems 1 |
|
to **M**. For example, if you swap columns 1 and 2, then everybody who had |
|
originally solved problem 1 will now be considered to have solved problem 2 |
|
(thus earning 4 points for it rather than 2), and vice versa. |
|
|
|
Of course, you'd like to use this opportunity to your benefit — it would be |
|
irresponsible to just let it pass by! However, it would be too suspicious if |
|
you simply made yourself win the whole competition. As such, you'd like to |
|
cause yourself to end up in 2nd place, such that you (participant 1) have |
|
exactly the second-highest score out of all **N** participants. Now you just |
|
need to determine whether or not this is achievable... |
|
|
|
### Input |
|
|
|
Input begins with an integer **T**, the number of scoreboards. |
|
For each scoreboard, there is first a line containing the space-separated |
|
integers **N** and **M**. |
|
Then, **N** lines follow, the _i_th of which contains a length-**M** string, |
|
the characters **Si,1** through **Si,M**. |
|
|
|
### Output |
|
|
|
For the _i_th scoreboard, print a line containing "Case #_i_: " followed by |
|
one character, either "Y" if you can end up in 2nd place, or "N" otherwise. |
|
|
|
### Constraints |
|
|
|
1 ≤ **T** ≤ 200 |
|
2 ≤ **N** ≤ 400 |
|
1 ≤ **M** ≤ 400 |
|
|
|
The sum of **N** * **M** across all **T** test cases is no greater than |
|
1,000,000. |
|
|
|
### Explanation of Sample |
|
|
|
In the first case, there's only one possible permutation of problems: [1]. |
|
This results in you having a score of 2 and participant 2 having a score of 0, |
|
which puts you in 1st place rather than 2nd. |
|
|
|
In the second case, if you preserve the original permutation of problems, [1, |
|
2], you'll have a score of 2 while participant 2 has a score of 4, putting you |
|
in 2nd place, as required. The permutation [2, 1] would have put you in 1st |
|
place instead. |
|
|
|
In the third case, if you choose the problem permutation [2, 1], the 4 |
|
participants' scores will be 4, 0, 6, and 2, respectively. This puts you in |
|
2nd place, as required. The problem permutation [1, 2] would have put you in |
|
3rd place instead. |
|
|
|
|