#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long a[(long long)(long long)(1e7 + 5)];
vector<long long> v;
void sieve(long long max = (long long)1e7) {
  for (long long i = 0; i <= max; i++) a[i] = 1;
  a[0] = a[1] = 0;
  for (long long i = 2; i <= (long long)sqrt(max); i++) {
    if (a[i] == 1) {
      for (long long j = i * i; j <= max; j += i) a[j] = 0;
      v.push_back(i);
    }
  }
  for (long long i = (long long)sqrt(max) + 1; i <= max; i++) {
    if (a[i] == 1) v.push_back(i);
  }
}
long long rr[] = {-1, 0, 1, 0};
long long cc[] = {0, 1, 0, -1};
string pathreq(pair<long long, long long> a, pair<long long, long long> b) {
  long long dx = b.first - a.first;
  long long dy = b.second - a.second;
  long long g = abs(dx);
  string ret = "";
  while (g--) ret += (dx < 0) ? 'U' : 'D';
  g = abs(dy);
  while (g--) ret += (dy < 0) ? 'L' : 'R';
  return ret;
}
long long n, m;
bool valid(long long x, long long y) {
  if (x < 0 || x >= n) return false;
  if (y < 0 || y >= m) return false;
  return true;
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  string s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  vector<pair<long long, long long> > vec;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        long long cnt = 0;
        for (long long k = 0; k < 4; k++) {
          long long x = i + rr[k];
          long long y = j + cc[k];
          if (valid(x, y) && s[x][y] == 'W') cnt++;
        }
        if (cnt == 4) return cout << "NO\n", 0;
        vec.push_back({i, j});
      }
    }
  }
  long long flg1 = 0, flg2 = 0, flg = 0;
  for (long long i = 0; i < vec.size(); i++) {
    for (long long j = i + 1; j < vec.size(); j++) {
      string path = pathreq(vec[i], vec[j]);
      long long x = vec[i].first, y = vec[i].second;
      flg1 = 0, flg2 = 0;
      for (long long k = 0; k < path.length(); k++) {
        if (path[k] == 'U')
          x -= 1;
        else if (path[k] == 'D')
          x += 1;
        else if (path[k] == 'L')
          y -= 1;
        else
          y += 1;
        if (valid(x, y) && s[x][y] == 'W') flg1 = 1;
      }
      reverse(path.begin(), path.end());
      x = vec[i].first, y = vec[i].second;
      for (long long k = 0; k < path.length(); k++) {
        if (path[k] == 'U')
          x -= 1;
        else if (path[k] == 'D')
          x += 1;
        else if (path[k] == 'L')
          y -= 1;
        else
          y += 1;
        if (valid(x, y) && s[x][y] == 'W') flg2 = 1;
      }
      if (flg1 && flg2) {
        flg = 1;
        break;
      }
    }
    if (flg) break;
  }
  if (flg)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
