#include <bits/stdc++.h>
using namespace std;
const int dir[][2] = {1, 0, 0, 1, -1, 0, 0, -1};
bool solve() {
  int h, w;
  cin >> h >> w;
  vector<string> board(h);
  for (auto &line : board) {
    cin >> line;
  }
  vector<pair<int, int> > blacks;
  for (int i = (int)(0); i < (int)(h); ++i) {
    for (int j = (int)(0); j < (int)(w); ++j) {
      if (board[i][j] == 'W') {
        continue;
      }
      blacks.push_back(make_pair((i), (j)));
    }
  }
  const int N = blacks.size();
  for (int i = (int)(0); i < (int)(N); ++i) {
    for (int j = (int)(i + 1); j < (int)(N); ++j) {
      bool f1 = true, f2 = true;
      if (blacks[i].second <= blacks[j].second) {
        for (int y = (int)(blacks[i].first); y < (int)(blacks[j].first + 1);
             ++y) {
          f1 &= board[y][blacks[i].second] == 'B';
          f2 &= board[y][blacks[j].second] == 'B';
        }
        for (int x = (int)(blacks[i].second); x < (int)(blacks[j].second + 1);
             ++x) {
          f1 &= board[blacks[j].first][x] == 'B';
          f2 &= board[blacks[i].first][x] == 'B';
        }
      } else {
        for (int y = (int)(blacks[i].first); y < (int)(blacks[j].first + 1);
             ++y) {
          f1 &= board[y][blacks[j].second] == 'B';
          f2 &= board[y][blacks[i].second] == 'B';
        }
        for (int x = (int)(blacks[j].second); x < (int)(blacks[i].second + 1);
             ++x) {
          f1 &= board[blacks[i].first][x] == 'B';
          f2 &= board[blacks[j].first][x] == 'B';
        }
      }
      if (!(f1 || f2)) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << (solve() ? "YES" : "NO") << endl;
  return 0;
}
