#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
using namespace std;
int gcd(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int bigmod(int b, int p, int m) {
  int ans = 1;
  b %= m;
  if (!b) return 0;
  while (p) {
    if (p & 1) ans = (ans * b) % m;
    p >>= 1;
    b = (b * b) % m;
  }
  return ans;
}
int ncr(int n, int r) {
  if (n < r) return 0ll;
  int ans = 1, k = min(n - r, r);
  for (int i = 1; i <= k; i++) ans = ans * (n - i + 1) / i;
  return ans;
}
long double eu(int x1, int y1, int x2, int y2) {
  int dx = abs(x1 - x2), dy = abs(y1 - y2);
  return sqrt(dx * dx + dy * dy);
}
int ham(string s, string t) {
  int ans = 0;
  for (int i = 0; i < s.size(); i++) ans += (s[i] != t[i]);
  return ans;
}
int ce(int a, int b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
bool cmp() { return 1; }
void gen() {}
void solve() {
  int n, m;
  cin >> n >> m;
  char a[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'B') {
        v.push_back(make_pair(i, j));
      }
    }
  }
  int vs = int(v.size());
  for (int i = 0; i < vs; i++) {
    for (int j = i + 1; j < vs; j++) {
      pair<int, int> q = v[i], r = v[j];
      if (q > r) swap(q, r);
      bool ok1 = 1, ok2 = 1;
      for (int k = q.first; k <= r.first; k++) {
        if (a[k][q.second] == 'W') {
          ok1 = 0;
          break;
        }
      }
      for (int k = q.second; k <= r.second; k++) {
        if (a[r.first][k] == 'W') {
          ok1 = 0;
          break;
        }
      }
      for (int k = r.second; k >= q.second; k--) {
        if (a[r.first][k] == 'W') {
          ok1 = 0;
          break;
        }
      }
      for (int k = q.second; k <= r.second; k++) {
        if (a[q.first][k] == 'W') {
          ok2 = 0;
          break;
        }
      }
      for (int k = r.second; k >= q.second; k--) {
        if (a[q.first][k] == 'W') {
          ok2 = 0;
          break;
        }
      }
      for (int k = q.first; k <= r.first; k++) {
        if (a[k][r.second] == 'W') {
          ok2 = 0;
          break;
        }
      }
      if (!ok1 && !ok2) {
        cout << "NO\n";
        return;
      }
    }
  }
  cout << "YES\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
}
