#include <bits/stdc++.h>
using namespace std;
int matrix[55][55], ans, n, m, cnt;
bool vis[55][55], tem[55][55];
void dfs(int x, int y, int d, int k) {
  if (x < 1 || y < 1 || x > n || y > m || tem[x][y] || k > 1 ||
      matrix[x][y] == 0)
    return;
  tem[x][y] = true;
  if (!vis[x][y]) {
    vis[x][y] = true;
    ans++;
  }
  if (d == 1) dfs(x + 1, y, d, k);
  if (d == 2) dfs(x - 1, y, d, k);
  if (d == 3) dfs(x, y - 1, d, k);
  if (d == 4) dfs(x, y + 1, d, k);
  for (int ix = 1; ix <= 4; ix++)
    if (ix != d && k == 0) {
      if (ix == 1) dfs(x + 1, y, ix, k + 1);
      if (ix == 2) dfs(x - 1, y, ix, k + 1);
      if (ix == 3) dfs(x, y - 1, ix, k + 1);
      if (ix == 4) dfs(x, y + 1, ix, k + 1);
    }
}
int main() {
  char ch;
  bool ok;
  while (scanf("%d%d", &n, &m) != EOF) {
    cnt = 0;
    ok = false;
    for (int ix1 = 1; ix1 <= n; ix1++)
      for (int ix2 = 1; ix2 <= m; ix2++) {
        scanf(" %c", &ch);
        if (ch == 'B') cnt++;
        matrix[ix1][ix2] = (ch == 'B' ? 1 : 0);
      }
    for (int a = 1; a <= n; a++)
      for (int b = 1; b <= m; b++) {
        if (ok) break;
        ok = false;
        if (matrix[a][b] == 1) {
          memset(vis, false, sizeof(vis));
          ans = 0;
          for (int ix = 1; ix <= 4; ix++) {
            memset(tem, false, sizeof(tem));
            dfs(a, b, ix, 0);
          }
          if (ans < cnt) {
            printf("NO\n");
            ok = true;
            break;
          }
        }
      }
    if (!ok) cout << "YES" << endl;
  }
  return 0;
}
