#include <bits/stdc++.h>
using namespace std;
unsigned long long paw(unsigned long long n, unsigned long long i) {
  unsigned long long res = 1;
  for (unsigned long long j = 0; j < i; j++) res *= 10;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  char tab[n][m];
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> tab[i][j];
      if (tab[i][j] == 'B') v.push_back(make_pair(i, j));
    }
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      if (v[i].first <= v[j].first && v[i].second >= v[j].second) {
        bool b = true;
        for (int k = min(v[i].first, v[j].first);
             k <= max(v[i].first, v[j].first); k++)
          if (tab[k][min(v[j].second, v[i].second)] != 'B') b = false;
        for (int k = min(v[i].second, v[j].second);
             k <= max(v[i].second, v[j].second); k++)
          if (tab[min(v[j].first, v[i].first)][k] != 'B') b = false;
        if (b) continue;
        b = true;
        for (int k = min(v[i].first, v[j].first);
             k <= max(v[i].first, v[j].first); k++)
          if (tab[k][max(v[j].second, v[i].second)] != 'B') b = false;
        for (int k = min(v[i].second, v[j].second);
             k <= max(v[i].second, v[j].second); k++)
          if (tab[max(v[j].first, v[i].first)][k] != 'B') b = false;
        if (!b) {
          cout << "NO";
          return 0;
        }
      } else {
        bool b = true;
        for (int k = min(v[i].first, v[j].first);
             k <= max(v[i].first, v[j].first); k++)
          if (tab[k][min(v[j].second, v[i].second)] != 'B') b = false;
        for (int k = min(v[i].second, v[j].second);
             k <= max(v[i].second, v[j].second); k++)
          if (tab[max(v[j].first, v[i].first)][k] != 'B') b = false;
        if (b) continue;
        b = true;
        for (int k = min(v[i].first, v[j].first);
             k <= max(v[i].first, v[j].first); k++)
          if (tab[k][max(v[j].second, v[i].second)] != 'B') b = false;
        for (int k = min(v[i].second, v[j].second);
             k <= max(v[i].second, v[j].second); k++)
          if (tab[min(v[j].first, v[i].first)][k] != 'B') b = false;
        if (!b) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
  return 0;
}
