#include <bits/stdc++.h>
using namespace std;
const int maxN = 60;
int n, m;
bool res = true;
char c[maxN][maxN];
bool check(int x1, int y1, int x2, int y2, int x3, int y3) {
  int x = x1, y = y1;
  while (x != x2 || y != y2) {
    if (c[x][y] == 'W') return false;
    if (x2 != x) {
      if (x2 < x)
        --x;
      else
        ++x;
    } else {
      if (y2 < y)
        --y;
      else
        ++y;
    }
  }
  while (x != x3 || y != y3) {
    if (c[x][y] == 'W') return false;
    if (x3 != x) {
      if (x3 < x)
        --x;
      else
        ++x;
    } else {
      if (y3 < y)
        --y;
      else
        ++y;
    }
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = (int)0; i <= (int)n - 1; ++i)
    for (int j = (int)0; j <= (int)m - 1; ++j) cin >> c[i][j];
  for (int x1 = (int)0; x1 <= (int)n - 1; ++x1)
    for (int y1 = (int)0; y1 <= (int)m - 1; ++y1) {
      if (c[x1][y1] == 'W') continue;
      for (int x2 = (int)0; x2 <= (int)n - 1; ++x2)
        for (int y2 = (int)0; y2 <= (int)m - 1; ++y2) {
          if (x1 == x2 && y1 == y2) continue;
          if (c[x2][y2] == 'W') continue;
          bool ok = false;
          if (check(x1, y1, x1, y2, x2, y2)) ok = true;
          if (check(x1, y1, x2, y1, x2, y2)) ok = true;
          if (!ok) res = false;
        }
    }
  printf(res ? "YES" : "NO");
}
