#include <bits/stdc++.h>
using namespace std;
char grid[55][55];
int n, m;
bool ispath(int x1, int y1, int x2, int y2) {
  int tx = x1, ty = y1;
  bool flag = true;
  while (x1 != x2) {
    if (grid[x1][y1] == 'W') {
      flag = false;
      break;
    }
    if (x1 < x2)
      x1++;
    else if (x1 > x2)
      x1--;
    if (grid[x1][y1] == 'W') {
      flag = false;
      break;
    }
  }
  while (y1 != y2) {
    if (grid[x1][y1] == 'W') {
      flag = false;
      break;
    }
    if (y1 < y2)
      y1++;
    else if (y1 > y2)
      y1--;
    if (grid[x1][y1] == 'W') {
      flag = false;
      break;
    }
  }
  if (flag) return true;
  flag = true;
  while (ty != y2) {
    if (grid[tx][ty] == 'W') {
      flag = false;
      break;
    }
    if (ty < y2)
      ty++;
    else if (ty > y2)
      ty--;
    if (grid[tx][ty] == 'W') {
      flag = false;
      break;
    }
  }
  while (tx != x2) {
    if (grid[tx][y2] == 'W') {
      flag = false;
      break;
    }
    if (tx < x2)
      tx++;
    else if (tx > x2)
      tx--;
    if (grid[tx][y2] == 'W') {
      flag = false;
      break;
    }
  }
  return flag;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> grid[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < n; k++) {
        for (int l = 0; l < m; l++) {
          if (grid[i][j] == 'B' && grid[k][l] == 'B') {
            if (!ispath(i, j, k, l)) {
              cout << "NO"
                   << "\n";
              return 0;
            }
          }
        }
      }
    }
  }
  cout << "YES"
       << "\n";
}
