#include <bits/stdc++.h>
using namespace std;
int mas[111][111];
int amount;
int dost;
bool used[111][111];
int d[4][2];
void dfs(int x, int y, int napr, int turn) {
  if (turn > 1) return;
  if (mas[x][y] == 0) return;
  if (!used[x][y]) {
    ++dost;
    used[x][y] = true;
  }
  int plus = 0;
  for (int newNapr = 0; newNapr < 4; ++newNapr) {
    if (((napr - newNapr + 4) % 4) == 2) continue;
    if (napr == newNapr)
      dfs(x + d[newNapr][0], y + d[newNapr][1], newNapr, turn);
    else
      dfs(x + d[newNapr][0], y + d[newNapr][1], newNapr, turn + 1);
  }
}
int main() {
  d[0][0] = 0;
  d[0][1] = -1;
  d[1][0] = 1;
  d[1][1] = 0;
  d[2][0] = 0;
  d[2][1] = 1;
  d[3][0] = -1;
  d[3][1] = 0;
  int n, m;
  cin >> n >> m;
  string a;
  for (int i = 1; i <= n; ++i) {
    cin >> a;
    for (int j = 1; j <= m; ++j) {
      if (a[j - 1] == 'W') {
        mas[j][i] = 0;
      } else {
        mas[j][i] = 1;
        ++amount;
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (mas[i][j] == 1) {
        for (int ii = 0; ii < 111; ++ii) {
          for (int jj = 0; jj < 111; ++jj) {
            used[ii][jj] = false;
          }
        }
        dost = 1;
        dfs(i, j - 1, 0, 0);
        dfs(i + 1, j, 1, 0);
        dfs(i, j + 1, 2, 0);
        dfs(i - 1, j, 3, 0);
        if (dost != amount) {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
