#include <bits/stdc++.h>
using namespace std;
char c;
int n, m, cnt, f[3600][3];
bool a[60][60], flag, heng[51][51][51], shu[51][51][51];
bool go(int x1, int y1, int x2, int y2) {
  if (heng[x1][min(y1, y2)][max(y1, y2)] && shu[y2][min(x1, x2)][max(x1, x2)])
    return true;
  if (heng[x2][min(y1, y2)][max(y1, y2)] && shu[y1][min(x1, x2)][max(x1, x2)])
    return true;
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c;
      if (c == 'B') a[i][j] = 1, f[++cnt][1] = i, f[cnt][2] = j;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j]) {
        heng[i][j][j] = true;
        for (int k = j + 1; k <= m; k++) {
          if (a[i][k])
            heng[i][j][k] = true;
          else
            break;
        }
      }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (a[j][i]) {
        shu[i][j][j] = true;
        for (int k = j + 1; k <= n; k++) {
          if (a[k][i])
            shu[i][j][k] = true;
          else
            break;
        }
      }
  flag = true;
  for (int i = 1; i < cnt; i++)
    for (int j = i + 1; j <= cnt; j++)
      if (!go(f[i][1], f[i][2], f[j][1], f[j][2])) {
        flag = false;
        break;
      }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
