#include <bits/stdc++.h>
using namespace std;
int n, m;
int heng[55][55], shu[55][55];
char c[55][55];
vector<pair<int, int> > ok;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'B') ok.push_back(make_pair(i, j));
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      heng[i][j] = heng[i][j - 1];
      shu[i][j] = shu[i - 1][j];
      if (c[i][j] == 'W') {
        heng[i][j]++;
        shu[i][j]++;
      }
    }
  for (int i = 0; i < ok.size(); i++)
    for (int j = 0; j < i; j++) {
      int x1 = ok[i].first, y1 = ok[i].second;
      int x2 = ok[j].first, y2 = ok[j].second;
      if (x1 == x2) {
        if (heng[x2][y2] != heng[x2][y1]) {
          cout << "NO";
          return 0;
        }
      } else if (y1 == y2) {
        if (shu[x2][y2] != shu[x1][y2]) {
          cout << "NO";
          return 0;
        }
      } else {
        if ((heng[x1][y2] != heng[x1][y1] || shu[x1][y2] != shu[x2][y2] ||
             c[x1][y2] == 'W') &&
            (heng[x2][y2] != heng[x2][y1] || shu[x1][y1] != shu[x2][y1] ||
             c[x2][y1] == 'W')) {
          cout << "NO";
          return 0;
        }
      }
    }
  cout << "YES";
  return 0;
}
