#include <bits/stdc++.h>
using namespace std;
void Fast_Read_Out() {
  ios_base::sync_with_stdio(0);
  cin.tie(), cout.tie();
}
void Random() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
unsigned int Time() {
  unsigned int time = clock() / 1000.00;
  return time;
}
const int inf = int(1e9) + 123;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
char a[55][55];
vector<int> pos;
bool used[55][55];
vector<pair<int, int> > v;
int n, m;
void dfs(int x, int y, int type = -1, int sum = 0, int xx = -1, int yy = -1) {
  used[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int sx = x + dx[i];
    int sy = y + dy[i];
    if (sx == xx && sy == yy) continue;
    if (sx >= 1 && sx <= n && sy >= 1 && sy <= m && a[sx][sy] == 'B' &&
        (type == -1 || type == i))
      dfs(sx, sy, i, sum, x, y);
    if (sx >= 1 && sx <= n && sy >= 1 && sy <= m && a[sx][sy] == 'B' &&
        type != i && !sum)
      dfs(sx, sy, i, sum + 1, x, y);
  }
}
int main() {
  Random();
  Fast_Read_Out();
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == 'B') v.push_back(make_pair(i, j));
  for (int i = 0; i < (int)(v.size()); i++) {
    memset(used, 0, sizeof used);
    dfs(v[i].first, v[i].second);
    for (int j = 0; j < (int)(v.size()); j++)
      if (!used[v[j].first][v[j].second]) cout << "NO", exit(0);
  }
  cout << "YES" << endl;
}
