#include <bits/stdc++.h>
bool p[50][50];
int n, m;
bool reach(int i, int j, int ii, int jj) {
  if (i == ii && j == jj) return true;
  int iI = i <= ii ? 1 : -1;
  int jI = j <= jj ? 1 : -1;
  int wC = 0;
  for (int i2 = i; i2 <= ii; i2 += iI) {
    wC += !p[i2][j] ? 1 : 0;
  }
  for (int j2 = j; j2 <= jj; j2 += jI) {
    wC += !p[ii][j2] ? 1 : 0;
  }
  int wC2 = 0;
  for (int j2 = j; j2 <= jj; j2 += jI) {
    wC2 += !p[i][j2] ? 1 : 0;
  }
  for (int i2 = i; i2 <= ii; i2 += iI) {
    wC2 += !p[i2][jj] ? 1 : 0;
  }
  return wC == 0 || wC2 == 0;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char c;
      scanf(" %c ", &c);
      p[i][j] = c == 'W' ? false : true;
    }
  }
  bool convex = true;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int ii = 0; ii < n; ++ii) {
        for (int jj = 0; jj < m; ++jj) {
          if (p[i][j] && p[ii][jj]) convex = convex && reach(i, j, ii, jj);
        }
      }
    }
  }
  printf("%s\n", !convex ? "NO" : "YES");
  return 0;
}
