#include <bits/stdc++.h>
using namespace std;
char grid[55][55];
bool reached[55][55];
int n, m, t, nb;
inline void recurse(int y, int x, int dir, bool canTurn) {
  if (y < 0 || y == n || x < 0 || x == m || grid[y][x] == 'W') return;
  if (!reached[y][x]) {
    t++;
    reached[y][x] = 1;
  }
  if (dir == 0) {
    recurse(y - 1, x, dir, canTurn);
    if (canTurn) {
      recurse(y, x - 1, 3, !canTurn);
      recurse(y, x + 1, 2, !canTurn);
    }
  } else if (dir == 1) {
    recurse(y + 1, x, dir, canTurn);
    if (canTurn) {
      recurse(y, x - 1, 3, !canTurn);
      recurse(y, x + 1, 2, !canTurn);
    }
  } else if (dir == 2) {
    recurse(y, x + 1, dir, canTurn);
    if (canTurn) {
      recurse(y - 1, x, 0, !canTurn);
      recurse(y + 1, x, 1, !canTurn);
    }
  } else {
    recurse(y, x - 1, dir, canTurn);
    if (canTurn) {
      recurse(y - 1, x, 0, !canTurn);
      recurse(y + 1, x, 1, !canTurn);
    }
  }
}
inline bool canReachOthers(int y, int x) {
  for (int i = 0; i < 4; i++) recurse(y, x, i, 1);
  return t == nb;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> grid[i][j];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) nb += grid[i][j] == 'B';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == 'B' && !canReachOthers(i, j)) {
        cout << "NO";
        return 0;
      }
      t = 0;
      for (int y = 0; y < n; y++)
        for (int x = 0; x < m; x++) reached[y][x] = 0;
    }
  }
  cout << "YES";
}
