#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
};
int n, m, ok = 0, xet[60][60];
string s[60];
int dx[5] = {0, 0, 0, 1, -1};
int dy[5] = {0, 1, -1, 0, 0};
point goc;
int BFS(point u) {
  queue<point> Q;
  Q.push(u);
  xet[u.x][u.y] = 1;
  while (!Q.empty()) {
    point z = Q.front();
    Q.pop();
    point tmp;
    for (int i = 1; i <= 4; i++)
      for (int j = 1; j <= 4; j++) {
        tmp.x = z.x + dx[i];
        tmp.y = z.y + dy[i];
        if (tmp.x >= 0 && tmp.x < n && tmp.y >= 0 && tmp.y < m)
          if (s[tmp.x][tmp.y] == 'B' && xet[tmp.x][tmp.y] == 0) {
            Q.push(tmp);
            xet[tmp.x][tmp.y] = 1;
          }
      }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] == 'B' && xet[i][j] == 0) return 0;
  return 1;
}
void thuchien() {
  if (goc.x == 1000) {
    cout << "NO" << endl;
    return;
  }
  memset(xet, 0, sizeof(xet));
  if (BFS(goc) == 0) {
    cout << "NO" << endl;
    return;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] == 'W') {
        point tmp;
        int dem = 0;
        for (int k = 1; k <= 4; k++) {
          tmp.x = i + dx[k];
          tmp.y = j + dy[k];
          if (tmp.x >= 0 && tmp.x < n && tmp.y >= 0 && tmp.y < m)
            if (s[tmp.x][tmp.y] == 'B') dem++;
        }
        if (dem >= 3) {
          cout << "NO" << endl;
          return;
        }
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        for (int k = i; k < n; k++)
          if (s[k][j] == 'W' && s[k + 1][j] == 'B') {
            cout << "NO" << endl;
            return;
          }
        for (int k = j; k < m; k++)
          if (s[i][k] == 'W' && s[i][k + 1] == 'B') {
            cout << "NO" << endl;
            return;
          }
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        for (int h = 0; h <= n; h++)
          for (int k = 0; k <= m; k++)
            if (s[h][k] == 'B') {
              if (s[i][k] == 'W' && s[h][j] == 'W') {
                cout << "NO" << endl;
                return;
              }
            }
      }
    }
  cout << "YES" << endl;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  goc.x = 1000;
  goc.y = 1000;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        goc.x = i;
        goc.y = j;
      }
    }
  thuchien();
  return 0;
}
