#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, cnt = 0;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) cnt += s[i][j] == 'B';
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        bool st[51][51];
        memset(st, 0, sizeof st);
        int cnt2 = 0;
        for (int k = j + 1; k < m; k++) {
          if (s[i][k] == 'B') {
            if (st[i][k] == 0) cnt2++;
            st[i][k] = 1;
            for (int kk = i - 1; kk >= 0; kk--)
              if (s[kk][k] == 'B') {
                if (st[kk][k] == 0) cnt2++;
                st[kk][k] = 1;
              } else
                break;
            for (int kk = i + 1; kk < n; kk++)
              if (s[kk][k] == 'B') {
                if (st[kk][k] == 0) cnt2++;
                st[kk][k] = 1;
              } else
                break;
          } else
            break;
        }
        for (int k = j - 1; k >= 0; k--) {
          if (s[i][k] == 'B') {
            if (st[i][k] == 0) cnt2++;
            st[i][k] = 1;
            for (int kk = i + 1; kk < n; kk++)
              if (s[kk][k] == 'B') {
                if (st[kk][k] == 0) cnt2++;
                st[kk][k] = 1;
              } else
                break;
            for (int kk = i - 1; kk >= 0; kk--)
              if (s[kk][k] == 'B') {
                if (st[kk][k] == 0) cnt2++;
                st[kk][k] = 1;
              } else
                break;
          } else
            break;
        }
        for (int k = i - 1; k >= 0; k--) {
          if (s[k][j] == 'B') {
            if (st[k][j] == 0) cnt2++;
            st[k][j] = 1;
            for (int kk = j + 1; kk < m; kk++)
              if (s[k][kk] == 'B') {
                if (st[k][kk] == 0) cnt2++;
                st[k][kk] = 1;
              } else
                break;
            for (int kk = j - 1; kk >= 0; kk--)
              if (s[k][kk] == 'B') {
                if (st[k][kk] == 0) cnt2++;
                st[k][kk] = 1;
              } else
                break;
          } else
            break;
        }
        for (int k = i + 1; k < n; k++) {
          if (s[k][j] == 'B') {
            if (st[k][j] == 0) cnt2++;
            st[k][j] = 1;
            for (int kk = j + 1; kk < m; kk++)
              if (s[k][kk] == 'B') {
                if (st[k][kk] == 0) cnt2++;
                st[k][kk] = 1;
              } else
                break;
            for (int kk = j - 1; kk >= 0; kk--)
              if (s[k][kk] == 'B') {
                if (st[k][kk] == 0) cnt2++;
                st[k][kk] = 1;
              } else
                break;
          } else
            break;
        }
        if (cnt2 != cnt - 1) {
          puts("NO");
          return 0;
        }
      }
    }
  }
  puts("YES");
  return 0;
}
