#include <bits/stdc++.h>
using namespace std;
int n, m;
string c[50];
vector<pair<int, int> > black;
bool find(int v) {
  int x = black[v].first;
  int y = black[v].second;
  bool f1 = 0, f2 = 0, f3 = 0, f4 = 0;
  for (int i = v + 1; i < black.size(); i++) {
    int x1 = black[i].first;
    int y1 = black[i].second;
    f1 = 0;
    f2 = 0;
    f3 = 0;
    f4 = 0;
    for (int j = min(x1, x); j <= max(x1, x); j++) {
      if (c[j][y] == 'W') f1 = 1;
      if (c[j][y1] == 'W') f2 = 1;
    }
    for (int j = min(y1, y); j <= max(y1, y); j++) {
      if (c[x][j] == 'W') f3 = 1;
      if (c[x1][j] == 'W') f4 = 1;
    }
    if ((f1 == 1 || f4 == 1) && (f2 == 1 || f3 == 1)) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (c[i][j] == 'B') black.push_back(make_pair(i, j));
  for (int i = 0; i < black.size(); i++) {
    if (find(i) == 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
