#include <bits/stdc++.h>
char str[64][64];
bool vis[64][64][4];
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int az[4] = {2, 3, 0, 1};
int n, m;
void DFS(int i, int j, int dir, int cost) {
  if (i < 0 || j < 0 || i >= n || j >= m) return;
  if (str[i][j] == 'W') return;
  if (vis[i][j][dir]) return;
  if (cost > 1) return;
  vis[i][j][dir] = 1;
  for (int k = 0; k < 4; ++k)
    if (k != az[dir]) DFS(i + dr[k], j + dc[k], k, cost + (dir != k));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", str[i]);
  bool f = 1;
  for (int i = 0; f && i < n; ++i)
    for (int j = 0; f && j < m; ++j)
      if (str[i][j] == 'B') {
        memset(vis, 0, sizeof(vis));
        for (int k = 0; k < 4; ++k) {
          vis[i][j][k] = 1;
          DFS(i + dr[k], j + dc[k], k, 0);
        }
        for (int i = 0; f && i < n; ++i)
          for (int j = 0; f && j < m; ++j)
            if (str[i][j] == 'B')
              f = vis[i][j][0] || vis[i][j][1] || vis[i][j][2] || vis[i][j][3];
      }
  if (f)
    puts("YES");
  else
    puts("NO");
  return 0;
}
