D. Symmetrical Isolation: The Battle of Black and White
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

You are playing a game called "Your Craft". In this game, you can freely create and destroy different types of blocks in a three-dimensional space filled with blocks.

Now, you have a grid composed of $$$N \times M$$$ cells beneath your feet. At the beginning, you covered these cells with white carpets, and then you went to sleep.

Unfortunately, while you were sleeping, the problem setter secretly replaced some of the white carpets with black carpets.

When you woke up and opened the game again, you found that your masterpiece had been tainted, and you were very angry! So you decided to make the best of the situation by keeping the existing black carpets unchanged and dyeing some of the white carpets black to satisfy the following two conditions:

  1. No two cells with black carpets can share a common edge, which means:
    • If the cell in the $$$i$$$-th row and $$$j$$$-th column contains a black carpet, then the cells in the $$$(i-1)$$$-th row and $$$j$$$-th column, $$$(i+1)$$$-th row and $$$j$$$-th column, $$$i$$$-th row and $$$(j-1)$$$-th column, and $$$i$$$-th row and $$$(j+1)$$$-th column cannot contain black carpets if they have carpets.
  2. The final pattern must have at least one horizontal or vertical line of symmetry, which means at least one of the following two propositions must be satisfied:
    • For any $$$i \in [1,N]$$$ and $$$j \in [1,M]$$$, the color of the carpet in the $$$i$$$-th row and $$$j$$$-th column must be the same as the color of the carpet in the $$$(N-i+1)$$$-th row and $$$j$$$-th column;
    • For any $$$i \in [1,N]$$$ and $$$j \in [1,M]$$$, the color of the carpet in the $$$i$$$-th row and $$$j$$$-th column must be the same as the color of the carpet in the $$$i$$$-th row and $$$(M-j+1)$$$-th column.

You need to determine whether you can achieve these two conditions.

Note: You cannot destroy the existing black carpets.

Input

The first line contains two integers $$$N$$$ and $$$M$$$ ($$$1\le N,M\le 100$$$), separated by a space, representing the size of the grid.

The next $$$N$$$ lines each contain a string $$$S$$$ of length $$$M$$$. In the string $$$S$$$, a character W indicates that this position has a white carpet, while a character B indicates that this position has a black carpet. No other characters will appear in the string.

Output

If you can satisfy the conditions given in the problem, output the string Yes; otherwise, output the string No.

The answer is case insensitive. For example, the strings yEs, Yes, yes, and YES will all be recognized as if you can satisfy the conditions.

Examples
Input
4 4
WWWW
WBWW
WWWW
WWWW
Output
No
Input
4 4
BWWB
WWWW
WWWW
WWWB
Output
Yes
Input
4 4
BWWW
WBWW
WWBW
WWWW
Output
No
Input
5 5
BWBWB
WBWBW
BWBWB
WBWBW
BWBWB
Output
Yes
Input
2 2
BB
WW
Output
No
Input
2 2
WW
WW
Output
Yes
Input
8 6
WWBWWW
BWWWWW
WBWWWW
WWWWBW
BWWWWW
WWBWWW
WBWWWW
BWWWWW
Output
No
Note

For the first sample:

The leftmost image shows the situation you saw when you woke up. You cannot achieve the conditions by changing white carpets to black carpets. The pictures in the middle and on the rightmost show two possible ways to replace the carpet, but they cannot satisfy the two requirements in the question (the middle image does not have a horizontal or vertical line of symmetry; in the rightmost image, the black carpets share a common edge). It can be proven that any way of changing the carpets does not satisfy the requirements, so output No.

For the second sample:

The image shows a valid way to change the carpets. You can change the white carpet in the lower left corner to black, which satisfies both requirements in the problem. Therefore, you should output Yes.

For the third sample:

The image shows one possible way to change the carpets, but it is not a valid one. Remember: only configurations with a horizontal or vertical line of symmetry are considered valid.

For the fourth sample:

As shown in the image, the situation you saw when you woke up is already valid, so you do not need to make any changes.

For the fifth sample: When you woke up, there were already two black carpets sharing a common edge, so you cannot change the white carpets to satisfy the requirements.

For the sixth sample: A pattern with all white carpets is also considered valid because it has a horizontal or vertical line of symmetry and does not have two black carpets sharing a common edge.