#include <bits/stdc++.h>
using namespace std;
const int inf = ~-(1 << 31);
int row[55][55], col[55][55];
char c[55][55];
int num[55][55];
bool chk(int x1, int y1, int x2, int y2) {
  if (num[x1][y1] == 1 || num[x2][y2] == 1) {
    return true;
  }
  if (row[x1][y1] == row[x1][y2] && col[x1][y2] == col[x2][y2] &&
      c[x1][y2] == 'B')
    return true;
  if (row[x2][y1] == row[x2][y2] && col[x1][y1] == col[x2][y1] &&
      c[x2][y1] == 'B')
    return true;
  return false;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'B')
        num[i][j] = 0;
      else
        num[i][j] = 1;
    }
  for (int i = 0; i < n; i++) {
    row[i][0] = num[i][0];
    for (int j = 1; j < m; j++) {
      row[i][j] = num[i][j] + row[i][j - 1];
    }
  }
  for (int i = 0; i < m; i++) {
    col[0][i] = num[0][i];
    for (int j = 1; j < n; j++) {
      col[j][i] = col[j - 1][i] + num[j][i];
    }
  }
  for (int i = 0; i < n * m; i++) {
    int x1 = i / m, y1 = i % m;
    for (int j = i + 1; j < n * m; j++) {
      int x2 = j / m, y2 = j % m;
      if (!chk(x1, y1, x2, y2)) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
