#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 1;
long long int n, m, i, j, l, k, x, y, a, b, cnt[3], sum[3];
vector<string> mat;
vector<pair<long long int, long long int> > Black;
void flood(long long int i, long long int j) {
  if (i < 0 || j < 0 || i >= n || j >= m || mat[i][j] == 'W') {
    return;
  }
  Black.push_back({i, j});
  mat[i][j] = 'W';
  flood(i + 1, j);
  flood(i - 1, j);
  flood(i, j + 1);
  flood(i, j - 1);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  vector<string> mati(n);
  for (long long int i = 0; i < n; i++) {
    cin >> mati[i];
  }
  mat = mati;
  for (long long int i = 0; i < n; i++) {
    bool flag = 0;
    for (long long int j = 0; j < m; j++) {
      if (mat[i][j] == 'B') {
        flag = 1;
        flood(i, j);
        break;
      }
    }
    if (flag) {
      break;
    }
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (mat[i][j] == 'B') {
        cout << "NO";
        return 0;
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    bool flag1 = 0, flag2 = 0;
    for (long long int j = 0; j < (m); j++) {
      if (mati[i][j] == 'B') {
        if (flag2) {
          cout << "NO";
          return 0;
        }
        flag1 = 1;
      }
      if (flag1) {
        if (mati[i][j] == 'W') {
          flag2 = 1;
        }
      }
    }
  }
  for (long long int j = 0; j < (m); j++) {
    bool flag1 = 0, flag2 = 0;
    for (long long int i = 0; i < n; i++) {
      if (mati[i][j] == 'B') {
        if (flag2) {
          cout << "NO";
          return 0;
        }
        flag1 = 1;
      }
      if (flag1) {
        if (mati[i][j] == 'W') {
          flag2 = 1;
        }
      }
    }
  }
  for (long long int i = 0; i < Black.size(); i++) {
    for (long long int j = 0; j < Black.size(); j++) {
      if ((mati[Black[i].first][Black[j].second] == 'W') &&
          (mati[Black[j].first][Black[i].second] == 'W')) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
