#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[57][57];
bool vis[57][57];
int chk(int x, int y) {
  memset(vis, 0, sizeof(vis));
  int tmp = y;
  int res = 0;
  while (y >= 0)
    if (arr[x][y])
      y--;
    else
      break;
  for (int j = y + 1; j < m; j++) {
    if (!arr[x][j]) break;
    int X = x;
    while (X < n) {
      vis[X][j] = 1;
      if (arr[X][j])
        res++, X++;
      else
        break;
    }
    X = x - 1;
    while (X >= 0) {
      vis[X][j] = 1;
      if (arr[X][j])
        res++, X--;
      else
        break;
    }
  }
  y = tmp;
  while (x >= 0)
    if (arr[x][y])
      x--;
    else
      break;
  for (int i = x + 1; i < n; i++) {
    if (!arr[i][y]) break;
    int Y = y;
    while (Y < m) {
      if (arr[i][Y])
        res += !vis[i][Y], Y++;
      else
        break;
    }
    Y = y - 1;
    while (Y >= 0) {
      if (arr[i][Y])
        res += !vis[i][Y], Y--;
      else
        break;
    }
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    for (int j = 0; j < m; ++j) {
      arr[i][j] = t[j] == 'B';
      cnt += t[j] == 'B';
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (arr[i][j]) {
        if (chk(i, j) != cnt) {
          puts("NO");
          return 0;
        }
      }
    }
  }
  puts("YES");
}
