#include <bits/stdc++.h>
int n, m, sol;
char s[100][100];
char viz[52][52];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
void baga(int x, int y, int k) {
  while (s[x][y]) {
    viz[x][y] = 1;
    x += dx[k];
    y += dy[k];
  }
}
int check(int x1, int y1, int x2, int y2) {
  int i, j;
  int ok1 = 1, ok2 = 1, ok3 = 1, ok4 = 1;
  for (i = x1; i <= x2; i++) {
    if (s[i][y1] == 0) ok1 = 0;
    if (s[i][y2] == 0) ok3 = 0;
  }
  for (j = y1; j <= y2; j++) {
    if (s[x1][j] == 0) ok2 = 0;
    if (s[x2][j] == 0) ok4 = 0;
  }
  return (ok1 && ok4) || (ok2 && ok3);
}
int main() {
  scanf("%d %d\n", &n, &m);
  int i, j, k, l;
  for (i = 1; i <= n; i++) {
    gets(s[i] + 1);
    for (j = 1; j <= m; j++)
      if (s[i][j] == 'B')
        s[i][j] = 1;
      else
        s[i][j] = 0;
  }
  sol = 1;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (s[i][j])
        for (k = 1; k <= n; k++)
          for (l = 1; l <= m; l++)
            if (s[k][l]) {
              sol = sol & check(i, j, k, l);
              sol++;
              sol--;
            }
  printf("%s\n", sol ? "YES" : "NO");
  return 0;
}
