#include <bits/stdc++.h>
using namespace std;
vector<long long> v[301], vv, v1;
long long a, b, c[1234567], c1[1234][1234], e, i, j, n, x, y, l, r, k;
string s, s1;
long long used[301];
long long ans;
bool ok[123];
set<long long> se;
char ch[1234][1234];
bool check(long long i, long long j, long long ii, long long jj) {
  if (i == ii) {
    if (j < jj) {
      for (int o = j; o <= jj; o++) {
        if (ch[i][o] == 'W') return false;
      }
    } else {
      for (int o = jj; o <= j; o++) {
        if (ch[i][o] == 'W') return false;
      }
    }
  } else {
    if (i < ii) {
      for (int o = i; o <= ii; o++) {
        if (ch[o][j] == 'W') return false;
      }
    } else {
      for (int o = ii; o <= i; o++) {
        if (ch[o][j] == 'W') return false;
      }
    }
  }
  return true;
}
bool check1(long long i, long long j, long long ii, long long jj) {
  long long x1, x2, y1, y2;
  x1 = i;
  y1 = jj;
  x2 = ii;
  y2 = j;
  if (check(i, j, x1, y1) == true && check(x1, y1, ii, jj) == true) {
    return true;
  }
  if (check(i, j, x2, y2) == true && check(x2, y2, ii, jj) == true) {
    return true;
  }
  return false;
}
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= k; j++) {
      cin >> ch[i][j];
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= k; j++) {
      for (long long ii = 1; ii <= n; ii++) {
        for (long long jj = 1; jj <= k; jj++) {
          if (ch[i][j] == 'B' && ch[ii][jj] == 'B') {
            if (i == ii || j == jj) {
              if (check(i, j, ii, jj) == false) {
                cout << "NO";
                exit(0);
              }
            } else {
              if (check1(i, j, ii, jj) == false) {
                cout << "NO";
                exit(0);
              }
            }
          }
        }
      }
    }
  }
  cout << "YES";
}
