#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  map<long long, map<long long, char>> arr;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) cin >> arr[i][j];
  vector<pair<long long, long long>> temp;
  for (long long i = 1; i <= n; i++) {
    long long count = 0;
    bool sachin = false;
    long long start;
    long long last;
    for (long long j = 1; j <= m; j++) {
      if (arr[i][j] == 'W' && count != 0) {
        sachin = true;
      } else if (arr[i][j] == 'B' && sachin == true) {
        cout << "NO";
        return 0;
      } else if (arr[i][j] == 'B' && sachin == false) {
        if (count == 0) {
          start = j;
        }
        count++;
        last = j;
      }
    }
    if (count == 0) {
      continue;
    } else {
      temp.push_back(make_pair(start, last));
    }
  }
  long long len = temp.size();
  long long laststart;
  long long lastend;
  for (long long i = 0; i < len; i++) {
    laststart = temp[i].first;
    lastend = temp[i].second;
    for (long long j = 0; j < len; j++) {
      long long start = temp[j].first;
      long long last = temp[j].second;
      if ((laststart >= start && last >= lastend) ||
          (laststart <= start && last <= lastend)) {
        continue;
      } else {
        cout << "NO";
        return 0;
      }
    }
  }
  temp.clear();
  for (long long j = 1; j <= m; j++) {
    long long count = 0;
    bool sachin = false;
    long long start;
    long long last;
    for (long long i = 1; i <= n; i++) {
      if (arr[i][j] == 'W' && count != 0) {
        sachin = true;
      } else if (arr[i][j] == 'B' && sachin == true) {
        cout << "NO";
        return 0;
      } else if (arr[i][j] == 'B' && sachin == false) {
        if (count == 0) {
          start = i;
        }
        count++;
        last = i;
      }
    }
    if (count == 0) {
      continue;
    } else {
      temp.push_back(make_pair(start, last));
    }
  }
  len = temp.size();
  for (long long i = 0; i < len; i++) {
    laststart = temp[i].first;
    lastend = temp[i].second;
    for (long long j = 0; j < len; j++) {
      long long start = temp[j].first;
      long long last = temp[j].second;
      if ((laststart >= start && last >= lastend) ||
          (laststart <= start && last <= lastend)) {
        continue;
      } else {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
