#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
bool visit[55][55];
int n, m;
char c[55][55];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
bool chk() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (visit[i][j] == false) {
        return false;
      }
    }
  return true;
}
void clear() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (c[i][j] == 'B')
        visit[i][j] = false;
      else
        visit[i][j] = true;
    }
}
void dfs(int i, int j, int num, bool change, int &li, int &lj) {
  visit[i][j] = true;
  int ni = i + dx[num], nj = j + dy[num];
  if (c[ni][nj] == 'B') {
    dfs(ni, nj, num, change, li, lj);
  }
  if (change == false) {
    for (int x = 0; x < 4; x++) {
      if (x == num) continue;
      if (c[i + dx[x]][j + dy[x]] == 'B') {
        dfs(i + dx[x], j + dy[x], x, true, li, lj);
      }
    }
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (c[i][j] == 'B') {
        clear();
        visit[i][j] = true;
        dfs(i, j, 0, false, i, j);
        dfs(i, j, 1, false, i, j);
        dfs(i, j, 2, false, i, j);
        dfs(i, j, 3, false, i, j);
        if (!chk()) {
          cout << "NO";
          return 0;
        }
      }
    }
  cout << "YES";
  return 0;
}
