#include <bits/stdc++.h>
using namespace std;
const long long LLMAX = 0x7fffffffffffffffLL;
const long long LLMIN = 0x8000000000000000LL;
const int IMAX = 0x7fffffff;
const int IMIN = 0x80000000;
const double eps = 10e-7;
const int maxn = 50 + 10;
vector<pair<int, int> > black;
int n, m;
int grid[maxn][maxn];
char str[maxn];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    black.clear();
    memset(grid, 0, sizeof grid);
    for (int i = 1; i <= n; i++) {
      scanf("%s", str);
      for (int j = 1; j <= m; j++) {
        if (str[j - 1] == 'B') {
          grid[i][j] = 1;
          black.push_back(make_pair(i, j));
        }
      }
    }
    int sz = black.size();
    bool judge = true;
    for (int i = 0; i < sz; i++) {
      for (int j = i + 1; j < sz; j++) {
        int ax = black[i].first;
        int ay = black[i].second;
        int bx = black[j].first;
        int by = black[j].second;
        bool judge1 = true;
        bool judge2 = true;
        for (int x = min(ax, bx); x <= max(ax, bx); x++) {
          if (!grid[x][ay]) judge1 = false;
          if (!grid[x][by]) judge2 = false;
        }
        for (int y = min(ay, by); y <= max(ay, by); y++) {
          if (!grid[bx][y]) judge1 = false;
          if (!grid[ax][y]) judge2 = false;
        }
        if (!judge1 && !judge2) {
          judge = false;
          break;
        }
      }
    }
    if (judge)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
