#include <bits/stdc++.h>
char a[60][60];
struct ele {
  int x, y;
};
std::vector<ele> bl;
bool check(int p, int q) {
  int x1, x2, y1, y2, t, c, d;
  x1 = bl[p].x;
  y1 = bl[p].y;
  x2 = bl[q].x;
  y2 = bl[q].y;
  if (x1 == x2) {
    if (y1 > y2) std::swap(y1, y2);
    for (int k = y1; k <= y2; k++) {
      if (a[x1][k] != 'B') return false;
    }
    return true;
  }
  if (y1 == y2) {
    if (x1 > x2) std::swap(x1, x2);
    for (int k = x1; k <= x2; k++) {
      if (a[k][y1] != 'B') return false;
    }
    return true;
  }
  if (x1 > x2) {
    std::swap(x1, x2);
    std::swap(y1, y2);
  }
  int flag = 1;
  for (int k = x1; k <= x2; k++) {
    if (a[k][y1] != 'B') flag = 0;
  }
  if (y1 > y2)
    c = y2, d = y1;
  else
    c = y1, d = y2;
  for (int k = c; k <= d; k++) {
    if (a[x2][k] != 'B') flag = 0;
  }
  if (flag) return true;
  flag = 1;
  for (int k = c; k <= d; k++) {
    if (a[x1][k] != 'B') flag = 0;
  }
  for (int k = x1; k <= x2; k++) {
    if (a[k][y2] != 'B') flag = 0;
  }
  if (flag)
    return true;
  else
    return false;
}
int main() {
  int n, m, k, i;
  scanf("%d%d", &n, &m);
  for (k = 0; k < n; k++) {
    scanf("%s", a[k]);
    for (i = 0; i < m; i++) {
      if (a[k][i] == 'B') bl.push_back(ele{k, i});
    }
  }
  int flag = 1;
  for (k = 0; k < bl.size(); k++) {
    for (i = 0; i < bl.size(); i++) {
      if (!check(k, i)) flag = 0;
    }
  }
  if (flag)
    printf("YES");
  else
    printf("NO");
}
