#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k, l, s, e, f = 0;
  vector<string> store;
  string str;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> str;
    store.push_back(str);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++)
      if (store[i][j] == 'B') break;
    s = j;
    for (j = m - 1; j >= 0; j--)
      if (store[i][j] == 'B') break;
    e = j;
    for (j = s; j <= e; j++) {
      if (store[i][j] == 'W') {
        f = 1;
        break;
      }
    }
    if (f) break;
  }
  if (f)
    cout << "NO" << endl;
  else {
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++)
        if (store[j][i] == 'B') break;
      s = j;
      for (j = n - 1; j >= 0; j--)
        if (store[j][i] == 'B') break;
      e = j;
      for (j = s; j <= e; j++) {
        if (store[j][i] == 'W') {
          f = 1;
          break;
        }
      }
      if (f) break;
    }
    if (f)
      cout << "NO" << endl;
    else {
      for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
          for (k = 0; k < n; k++) {
            for (l = 0; l < m; l++) {
              if (i != k && j != l && store[i][j] == 'B' &&
                  store[k][l] == 'B') {
                if (store[i][l] == 'W' && store[k][j] == 'W') {
                  f = 1;
                  break;
                }
              }
            }
            if (f) break;
          }
          if (f) break;
        }
        if (f) break;
      }
      if (f)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
  return 0;
}
