#include <bits/stdc++.h>
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <typename T>
T nCr(T n, T r) {
  if (r > n - r) r = n - r;
  int ans = 1, i;
  for (i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }
  return ans;
}
using namespace std;
const int N = 60;
int n, m, a[N][N];
char s[N];
void iz() {
  printf("NO\n");
  exit(0);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++)
      if (s[j] == 'B') a[i][j] = 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int x = i; x <= n; x++)
        for (int y = 1; y <= m; y++)
          if ((i != x || j != y) && a[i][j] && a[x][y]) {
            int xm = min(i, x), xv = max(i, x);
            int ym = min(j, y), yv = max(j, y);
            if (x == i) {
              for (int k = ym; k <= yv; k++)
                if (!a[i][k]) iz();
            } else if (y == j) {
              for (int k = xm; k <= xv; k++)
                if (!a[k][j]) iz();
            } else {
              bool b0 = 0, b1 = 0, b2 = 0, b3 = 0;
              for (int k = xm; k <= xv; k++) b0 |= !a[k][j], b1 |= !a[k][y];
              for (int k = ym; k <= yv; k++) b2 |= !a[i][k], b3 |= !a[x][k];
              if ((b0 || b3) && (b1 || b2)) iz();
            }
          }
  printf("YES\n");
  return 0;
}
