#include <bits/stdc++.h>
using namespace std;
int n, m;
bool t[51][51];
vector<vector<char> > u;
int make2(int xx, int yy, int d);
int make1(int xx, int yy) {
  if (t[yy][xx] == false) return 0;
  int res = 1;
  u = vector<vector<char> >(n, vector<char>(m, 0));
  u[yy][xx] = true;
  int x = xx - 1, y = yy;
  while (x >= 0) {
    if (t[y][x] == false) break;
    if (u[y][x] == false) res += 1;
    u[y][x] = true;
    res += make2(x, y, 2);
    res += make2(x, y, 3);
    x--;
  }
  x = xx + 1, y = yy;
  while (x < m) {
    if (t[y][x] == false) break;
    if (u[y][x] == false) res += 1;
    u[y][x] = true;
    res += make2(x, y, 2);
    res += make2(x, y, 3);
    x++;
  }
  x = xx, y = yy - 1;
  while (y >= 0) {
    if (t[y][x] == false) break;
    if (u[y][x] == false) res += 1;
    u[y][x] = true;
    res += make2(x, y, 0);
    res += make2(x, y, 1);
    y--;
  }
  x = xx, y = yy + 1;
  while (y < n) {
    if (t[y][x] == false) break;
    if (u[y][x] == false) res += 1;
    u[y][x] = true;
    res += make2(x, y, 0);
    res += make2(x, y, 1);
    y++;
  }
  return res;
}
int make2(int xx, int yy, int d) {
  int res = 0;
  int x = xx, y = yy;
  switch (d) {
    case 0:
      x = xx - 1;
      while (x >= 0) {
        if (t[y][x] == false) break;
        if (u[y][x] == false) res += 1;
        u[y][x] = true;
        x--;
      }
      break;
    case 1:
      x = xx + 1;
      while (x < m) {
        if (t[y][x] == false) break;
        if (u[y][x] == false) res += 1;
        u[y][x] = true;
        x++;
      }
      break;
    case 2:
      y = yy - 1;
      while (y >= 0) {
        if (t[y][x] == false) break;
        if (u[y][x] == false) res += 1;
        u[y][x] = true;
        y--;
      }
      break;
    case 3:
      y = yy + 1;
      while (y < n) {
        if (t[y][x] == false) break;
        if (u[y][x] == false) res += 1;
        u[y][x] = true;
        y++;
      }
      break;
  }
  return res;
}
int main() {
  int all = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      t[i][j] = (c == 'B');
      if (t[i][j]) all++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (t[i][j] == false) continue;
      int res = make1(j, i);
      if (res < all) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
