#include <bits/stdc++.h>
using namespace std;
int a[60][60];
int flag[60][60], known[60][60];
int n, m;
int ans;
int check();
void dfs();
void explore(int x, int y, int turned, int dir);
int main() {
  int i, j;
  n = ({
    int x;
    scanf("%d", &x);
    x;
  });
  m = ({
    int x;
    scanf("%d", &x);
    x;
  });
  memset(a, 0, sizeof a);
  char temp[60];
  for (i = 1; i <= n; i++) {
    scanf("%s", temp);
    for (j = 1; j <= m; j++) {
      if (temp[j - 1] == 'B') a[i][j] = 1;
    }
  }
  dfs();
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
void dfs() {
  int i, j;
  int ret;
  ans = 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == 0) continue;
      memset(known, 0, sizeof known);
      memset(flag, 0, sizeof flag);
      known[i][j] = 1;
      flag[i][j] = 1;
      if (a[i][j - 1] == 1) {
        explore(i, j - 1, 0, 0);
      }
      if (a[i - 1][j] == 1) {
        explore(i - 1, j, 0, 1);
      }
      if (a[i][j + 1] == 1) {
        explore(i, j + 1, 0, 2);
      }
      if (a[i + 1][j] == 1) {
        explore(i + 1, j, 0, 3);
      }
      ret = check();
      if (ret == 0) {
        ans = 0;
        return;
      }
    }
  }
}
void explore(int x, int y, int turned, int dir) {
  flag[x][y] = 1;
  known[x][y] = 1;
  int i = x, j = y;
  if (a[i][j - 1] == 1) {
    if (dir == 0) {
      explore(i, j - 1, turned, 0);
    }
  }
  if (a[i - 1][j] == 1) {
    if (dir == 1) {
      explore(i - 1, j, turned, 1);
    }
  }
  if (a[i][j + 1] == 1) {
    if (dir == 2) {
      explore(i, j + 1, turned, 2);
    }
  }
  if (a[i + 1][j] == 1) {
    if (dir == 3) {
      explore(i + 1, j, turned, 3);
    }
  }
  if (a[i][j - 1] == 1) {
    if (dir != 0) {
      if (turned == 0) {
        explore(i, j - 1, 1, 0);
      }
    }
  }
  if (a[i - 1][j] == 1) {
    if (dir != 1) {
      if (turned == 0) {
        explore(i - 1, j, 1, 1);
      }
    }
  }
  if (a[i][j + 1] == 1) {
    if (dir != 2) {
      if (turned == 0) {
        explore(i, j + 1, 1, 2);
      }
    }
  }
  if (a[i + 1][j] == 1) {
    if (dir != 3) {
      if (turned == 0) {
        explore(i + 1, j, 1, 3);
      }
    }
  }
}
int check() {
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] == 1) {
        if (flag[i][j] == 0) return 0;
      }
    }
  }
  return 1;
}
