#include <bits/stdc++.h>
using namespace std;
const int N = 55;
char matrix[N][N];
int prefStb[N][N];
int prefStr[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> matrix[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      prefStr[i][j] = prefStr[i][j - 1] + (matrix[i][j] == 'B' ? 1 : 0);
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++)
      prefStb[i][j] = prefStb[i - 1][j] + (matrix[i][j] == 'B' ? 1 : 0);
  bool flag = true;
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++)
      for (int c = 1; c <= n; c++)
        for (int d = 1; d <= m; d++) {
          if (matrix[a][b] != 'B' || matrix[c][d] != 'B') continue;
          if (prefStr[a][max(d, b)] - prefStr[a][min(d, b) - 1] !=
              max(d, b) - min(d, b) + 1)
            if (prefStr[c][max(d, b)] - prefStr[c][min(d, b) - 1] !=
                max(d, b) - min(d, b) + 1)
              flag = false;
          if (prefStb[max(a, c)][d] - prefStb[min(a, c) - 1][d] !=
              max(a, c) - min(a, c) + 1)
            if (prefStb[max(a, c)][b] - prefStb[min(a, c) - 1][b] !=
                max(a, c) - min(a, c) + 1)
              flag = false;
        }
  cout << (flag ? "YES" : "NO") << "\n";
  return 0;
}
