#include <bits/stdc++.h>
using namespace std;
char s[55][55];
int n, m;
bool dfs(int x1, int y1, int x2, int y2) {
  int d;
  if (x1 < x2)
    d = 1;
  else
    d = -1;
  int i = x1;
  while (i != x2 && s[i][y1] == 'B') i += d;
  if (i == x2) {
    if (y1 < y2)
      d = 1;
    else
      d = -1;
    i = y1;
    while (i != y2 && s[x2][i] == 'B') i += d;
    if (i == y2) return true;
  }
  if (y1 < y2)
    d = 1;
  else
    d = -1;
  i = y1;
  while (i != y2 && s[x1][i] == 'B') i += d;
  if (i == y2) {
    if (x1 < x2)
      d = 1;
    else
      d = -1;
    i = x1;
    while (i != x2 && s[i][y2] == 'B') i += d;
    if (i == x2) return true;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int x1 = 0; x1 < n; x1++)
    for (int y1 = 0; y1 < m; y1++)
      if (s[x1][y1] == 'B') {
        for (int x2 = 0; x2 < n; x2++)
          for (int y2 = 0; y2 < m; y2++)
            if (s[x2][y2] == 'B' && dfs(x1, y1, x2, y2) == 0) {
              puts("NO");
              return 0;
            }
      }
  puts("YES");
  return 0;
}
