#include <bits/stdc++.h>
using namespace std;
int n, m;
char g[60][60];
int sum1[60][60], sum2[60][60];
bool check(int x1, int y1, int x2, int y2) {
  if (x1 > x2) {
    swap(x1, x2);
    swap(y1, y2);
  }
  int k2 = max(y1, y2), k1 = min(y1, y2);
  if (sum1[x1][k2] == sum1[x1][k1 - 1] && sum2[y2][x2] == sum2[y2][x1 - 1])
    return true;
  if (sum1[x2][k2] == sum1[x2][k1 - 1] && sum2[y1][x2] == sum2[y1][x1 - 1])
    return true;
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> g[i][j];
      sum1[i][j] = sum1[i][j - 1];
      sum2[j][i] = sum2[j][i - 1];
      if (g[i][j] == 'W') sum1[i][j]++, sum2[j][i]++;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (g[i][j] == 'W') continue;
      for (int a = 1; a <= n; a++)
        for (int b = 1; b <= m; b++) {
          if (g[a][b] == 'W') continue;
          if (!check(i, j, a, b)) {
            cout << "NO" << endl;
            return 0;
          }
        }
    }
  cout << "YES" << endl;
  return 0;
}
