#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
long long int n, m;
string s[50];
void solve() {
  cin >> n >> m;
  for (long long int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<pair<long long int, long long int>> v;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        v.push_back({i, j});
      }
    }
  }
  for (long long int i = 0; i < v.size(); i++) {
    for (long long int j = i + 1; j < v.size(); j++) {
      long long int x1, x2, y1, y2;
      x1 = v[i].first;
      y1 = v[i].second;
      x2 = v[j].first;
      y2 = v[j].second;
      long long int sx = x1, sy = y1;
      bool ans = true;
      while (x1 < x2) {
        if (s[x1][y1] != 'B') {
          ans = false;
          break;
        }
        x1++;
      }
      if (y1 < y2) {
        while (y1 < y2) {
          if (s[x1][y1] != 'B') {
            ans = false;
            break;
          }
          y1++;
        }
      } else {
        while (y1 > y2) {
          if (s[x1][y1] != 'B') {
            ans = false;
            break;
          }
          y1--;
        }
      }
      if (ans == true) {
        continue;
      }
      x1 = v[i].first;
      y1 = v[i].second;
      x2 = v[j].first;
      y2 = v[j].second;
      ans = true;
      if (y1 < y2) {
        while (y1 < y2) {
          if (s[x1][y1] != 'B') {
            ans = false;
            break;
          }
          y1++;
        }
      } else {
        while (y1 > y2) {
          if (s[x1][y1] != 'B') {
            ans = false;
            break;
          }
          y1--;
        }
      }
      while (x1 < x2) {
        if (s[x1][y1] != 'B') {
          ans = false;
          break;
        }
        x1++;
      }
      if (ans == false) {
        cout << "NO" << '\n';
        return;
      }
    }
  }
  cout << "YES" << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
}
