#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e11;
const long long NINF = -1e11;
const long long epsilon = 1e-9;
long long fast_pow(long long base, long long exp, long long mod) {
  if (exp == 0) return 1;
  if (exp == 1) return base % mod;
  long long half = fast_pow(base, exp / 2, mod);
  if (exp % 2 == 0)
    return (half % mod * half % mod) % mod;
  else
    return ((half % mod * half % mod) % mod * base % mod) % mod;
}
long long fast_pow_iter(long long base, long long exp, long long mod) {
  long long ans = 1;
  while (exp > 0) {
    if (exp & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long gcd_extended(long long a, long long b, long long& s, long long& t) {
  if (b == 0) {
    s = 1;
    t = 0;
    return a;
  }
  long long s1, t1;
  long long d = gcd_extended(b, a % b, s1, t1);
  s = t1;
  t = s1 - t1 * (a / b);
  return d;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  char mat[n][m];
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> mat[i][j];
      if (mat[i][j] == 'B') {
        v.push_back(make_pair(i, j));
      }
    }
  }
  for (long long i = 0; i < v.size(); i++) {
    for (long long j = i + 1; j < v.size(); j++) {
      pair<long long, long long> p1 = v[i], p2 = v[j];
      if (p1.first > p2.first) swap(p1, p2);
      bool isPoss = true;
      for (long long k = p1.first; k <= p2.first; k++) {
        if (mat[k][p1.second] != 'B') {
          isPoss = false;
          break;
        }
      }
      if (isPoss) {
        for (long long k = min(p1.second, p2.second);
             k <= max(p1.second, p2.second); k++) {
          if (mat[p2.first][k] != 'B') {
            isPoss = false;
            break;
          }
        }
      }
      if (isPoss) {
        continue;
      }
      isPoss = true;
      for (long long k = p1.first; k <= p2.first; k++) {
        if (mat[k][p2.second] != 'B') {
          isPoss = false;
          break;
        }
      }
      if (isPoss) {
        for (long long k = min(p1.second, p2.second);
             k <= max(p1.second, p2.second); k++) {
          if (mat[p1.first][k] != 'B') {
            isPoss = false;
            break;
          }
        }
      }
      if (!isPoss) {
        cout << "NO\n";
        return;
      }
    }
  }
  cout << "YES\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int total_cases = 1;
  for (int t = 1; t <= total_cases; t++) {
    solve();
  }
  return 0;
}
