#include <bits/stdc++.h>
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  char c;
  scanf("%c", &c);
  int i, j;
  char word[n + 2][m + 2];
  for (i = 0; i < n + 2; i++)
    for (j = 0; j < m + 2; j++) word[i][j] = 'W';
  int v[n + 1], h[m + 1];
  for (i = 0; i <= n; i++) v[i] = 0;
  for (j = 0; j <= m; j++) h[j] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%c", &word[i][j]);
      if (word[i][j] == 'B') {
        v[i] += 1;
        h[j] += 1;
      }
    }
    scanf("%c", &c);
  }
  int left = m + 1, right = 0;
  for (j = 1; j <= m; j++) {
    if ((h[j] > 0) && (j < left)) left = j;
    if ((h[j] > 0) && (j > right)) right = j;
  }
  int up = 0, down = n + 1;
  for (i = 1; i <= n; i++) {
    if ((v[i] > 0) && (i > up)) up = i;
    if ((v[i] > 0) && (i < down)) down = i;
  }
  int notTrue = 0;
  for (i = down; i <= up; i++) {
    if (v[i] == 0)
      notTrue = 1;
    else {
      int black = 0;
      for (j = left; j <= right; j++) {
        if ((word[i][j] == 'B') && (black == 0)) black = 1;
        if ((word[i][j] == 'W') && (black == 1)) black = 2;
        if ((word[i][j] == 'B') && (black == 2)) notTrue = 1;
      }
    }
  }
  for (j = left; j <= right; j++) {
    if (h[j] == 0)
      notTrue = 1;
    else {
      int black = 0;
      for (i = down; i <= up; i++) {
        if ((word[i][j] == 'B') && (black == 0)) black = 1;
        if ((word[i][j] == 'W') && (black == 1)) black = 2;
        if ((word[i][j] == 'B') && (black == 2)) notTrue = 1;
      }
    }
  }
  while (up > down) {
    int lv = right, pv = left, ln = right, pn = left;
    for (j = left; j <= right; j++) {
      if ((word[up][j] == 'B') && (lv > j)) lv = j;
      if ((word[up][j] == 'B') && (pv < j)) pv = j;
      if ((word[down][j] == 'B') && (ln > j)) ln = j;
      if ((word[down][j] == 'B') && (pn < j)) pn = j;
    }
    if (lv > ln) lv = ln;
    if (ln > lv) ln = lv;
    if (pn < pv) pn = pv;
    if (pv < pn) pv = pn;
    if (((word[up][ln] == 'W') && (word[up][pn] == 'B') &&
         (word[down][lv] == 'B') && (word[down][pv] == 'W')) ||
        ((word[down][lv] == 'W') && (word[down][pv] == 'B') &&
         (word[up][ln] == 'B') && (word[up][pn] == 'W')))
      notTrue = 1;
    --up;
    ++down;
  }
  if (notTrue == 0) {
    printf("YES");
  } else {
    printf("NO");
  }
  return 0;
}
