#include <bits/stdc++.h>
using namespace std;
string b[51];
bool check(pair<int, int> f, pair<int, int> s) {
  bool r1 = true, r2 = true, c1 = true, c2 = true;
  for (int i = f.first; i <= s.first; i++) {
    if (b[i][f.second] == 'W') c1 = false;
    if (b[i][s.second] == 'W') c2 = false;
  }
  for (int i = s.first; i <= f.first; i++) {
    if (b[i][f.second] == 'W') c1 = false;
    if (b[i][s.second] == 'W') c2 = false;
  }
  for (int i = f.second; i <= s.second; i++) {
    if (b[f.first][i] == 'W') r1 = false;
    if (b[s.first][i] == 'W') r2 = false;
  }
  for (int i = s.second; i <= f.second; i++) {
    if (b[f.first][i] == 'W') r1 = false;
    if (b[s.first][i] == 'W') r2 = false;
  }
  return (c1 && r2) || (c2 && r1);
}
vector<pair<int, int> > v;
int main() {
  int r, c;
  cin.tie(0);
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    cin >> b[i];
    for (int j = 0; j < c; j++)
      if (b[i][j] == 'B') v.push_back({i, j});
  }
  int sz = v.size();
  for (int i = 0; i < sz; i++)
    for (int j = i + 1; j < sz; j++) {
      if (!check(v[i], v[j])) {
        cout << "NO";
        return 0;
      };
    }
  cout << "YES";
  return 0;
}
