#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[55][55], n, m, numB = 0, fX, fY;
  char c;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> c;
      if (c == 'W')
        arr[i][j] = 1;
      else {
        arr[i][j] = 0;
        numB++;
        if (numB == 1) fX = i, fY = j;
      }
    }
  bool vis[55][55];
  memset(vis, 0, sizeof(vis));
  if (numB == 0) {
    cout << "YES";
    return 0;
  }
  queue<pair<int, int> > q;
  q.push(make_pair(fX, fY));
  vis[fX][fY] = 1;
  numB--;
  while (q.size() > 0) {
    pair<int, int> p = q.front();
    q.pop();
    int x[] = {1, 0, -1, 0};
    int y[] = {0, 1, 0, -1};
    for (int i = 0; i < 4; i++)
      if (p.first + x[i] >= 0 && p.first + x[i] < n && p.second + y[i] >= 0 &&
          p.second + y[i] < m)
        if (!vis[p.first + x[i]][p.second + y[i]] &&
            !arr[p.first + x[i]][p.second + y[i]])
          vis[p.first + x[i]][p.second + y[i]] = 1,
                                         q.push(make_pair(p.first + x[i],
                                                          p.second + y[i])),
                                         numB--;
  }
  if (numB != 0) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int x = 0;
    if (arr[i][0] == 0) x++;
    for (int j = 0; j < m - 1; j++)
      if (arr[i][j] && !arr[i][j + 1]) x++;
    if (x > 1) {
      cout << "NO";
      return 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int x = 0;
    if (arr[0][i] == 0) x++;
    for (int j = 0; j < n - 1; j++)
      if (arr[j][i] && !arr[j + 1][i]) x++;
    if (x > 1) {
      cout << "NO";
      return 0;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (arr[i][j]) continue;
      bool hor[55], ver[55];
      memset(hor, 0, sizeof(hor));
      memset(ver, 0, sizeof(ver));
      for (int k = 0; k < n; k++)
        if (!arr[k][j]) hor[k] = 1;
      for (int k = 0; k < m; k++)
        if (!arr[i][k]) ver[k] = 1;
      for (int k = 0; k < n; k++)
        for (int l = 0; l < m; l++)
          if (!arr[k][l])
            if (!hor[k] && !ver[l]) {
              cout << "NO";
              return 0;
            }
    }
  cout << "YES";
  return 0;
}
