#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e3;
int nx[4] = {1, 0, -1, 0};
int ny[4] = {0, 1, 0, -1};
char a[MXN][MXN];
int n, m;
bool u[MXN][MXN];
void update() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      u[i][j] = 0;
    }
  }
}
bool check() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!u[i][j] && a[i][j] == 'B') return false;
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 'W') continue;
      for (int k = i; k >= 1; k--) {
        if (a[k][j] == 'W') break;
        u[k][j] = 1;
        for (int z = j; z >= 1; z--) {
          if (a[k][z] == 'W') break;
          u[k][z] = 1;
        }
        for (int z = j; z <= m; z++) {
          if (a[k][z] == 'W') break;
          u[k][z] = 1;
        }
      }
      for (int k = i; k <= n; k++) {
        if (a[k][j] == 'W') break;
        u[k][j] = 1;
        for (int z = j; z >= 1; z--) {
          if (a[k][z] == 'W') break;
          u[k][z] = 1;
        }
        for (int z = j; z <= m; z++) {
          if (a[k][z] == 'W') break;
          u[k][z] = 1;
        }
      }
      for (int k = j; k >= 1; k--) {
        if (a[i][k] == 'W') break;
        u[i][k] = 1;
        for (int z = i; z >= 1; z--) {
          if (a[z][k] == 'W') break;
          u[z][k] = 1;
        }
        for (int z = i; z <= n; z++) {
          if (a[z][k] == 'W') break;
          u[z][k] = 1;
        }
      }
      for (int k = j; k <= m; k++) {
        if (a[i][k] == 'W') break;
        u[i][k] = 1;
        for (int z = i; z >= 1; z--) {
          if (a[z][k] == 'W') break;
          u[z][k] = 1;
        }
        for (int z = i; z <= n; z++) {
          if (a[z][k] == 'W') break;
          u[z][k] = 1;
        }
      }
      if (!check()) {
        cout << "NO";
        return 0;
      }
      update();
    }
  }
  cout << "YES";
  return 0;
}
