#include <bits/stdc++.h>
using namespace std;
char mp[55][55];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n, m;
bool ans;
bool check1(int from, int to, int p) {
  if (from > to) {
    for (int i = from; i > to; i--)
      if (mp[i][p] != 'B') return false;
  } else {
    for (int i = from; i < to; i++)
      if (mp[i][p] != 'B') return false;
  }
  return true;
}
bool check(int from, int to, int p) {
  if (from > to) {
    for (int i = from; i > to; i--)
      if (mp[p][i] != 'B') return false;
  } else {
    for (int i = from; i < to; i++)
      if (mp[p][i] != 'B') return false;
  }
  return true;
}
void solve(int x, int y) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (mp[i][j] == 'B' && (i != x || j != y))
        if (check1(i, x, j) && check(j, y, x) ||
            check1(i, x, y) && check(j, y, i))
          continue;
        else {
          ans = true;
          return;
        }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  ans = false;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (ans) {
        puts("NO");
        return 0;
      }
      if (mp[i][j] == 'B') {
        solve(i, j);
      }
    }
  puts("YES");
  return 0;
}
