#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  char **a = new char *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new char[m + 1];
    cin >> a[i];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < n; k++)
        for (int l = 0; l < m; l++) {
          if (i == k && j == l) {
            continue;
          }
          if (a[i][j] == 'W' || a[k][l] == 'W') {
            continue;
          }
          bool found1 = true;
          for (int i1 = j; i1 <= l; i1++) {
            if (a[i][i1] == 'W') {
              found1 = false;
              break;
            }
          }
          for (int i1 = i; i1 <= k; i1++) {
            if (a[i1][l] == 'W') {
              found1 = false;
              break;
            }
          }
          if (found1) {
            continue;
          }
          found1 = true;
          for (int i1 = i; i1 <= k; i1++) {
            if (a[i1][j] == 'W') {
              found1 = false;
              break;
            }
          }
          for (int i1 = j; i1 <= l; i1++) {
            if (a[k][i1] == 'W') {
              found1 = false;
              break;
            }
          }
          if (found1) {
            continue;
          } else {
            cout << "NO";
            return 0;
          }
        }
  cout << "YES";
}
