#include <bits/stdc++.h>
using namespace std;
int main() {
  char p[55][55];
  int k, i, j, s, n, m, inf;
  while (cin >> n >> m) {
    for (i = 0; i < n; i++) cin >> p[i];
    inf = 0;
    for (i = 0; i < n; i++) {
      int num = 0, kk = 1, pos;
      for (j = 0; j < m; j++) {
        if (p[i][j] == 'B') {
          if (num && j - pos != 1) {
            kk = 0;
            break;
          }
          pos = j;
          num++;
        }
      }
      if (!kk) inf = 1;
      if (num) {
        for (j = 0; j < m; j++)
          if (!inf && p[i][j] == 'B') {
            for (k = i + 1; k < n; k++) {
              for (s = 0; s < m; s++)
                if (p[k][s] == 'B') {
                  int k1 = 0, k2 = 0;
                  if (j >= s) {
                    int lm = 0;
                    for (int lol = s; lol <= j; lol++)
                      if (p[i][lol] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k1++;
                    lm = 0;
                    for (int lol = i; lol <= k; lol++)
                      if (p[lol][s] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k1++;
                    lm = 0;
                    for (int lol = s; lol <= j; lol++)
                      if (p[k][lol] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k2++;
                    lm = 0;
                    for (int lol = i; lol <= k; lol++)
                      if (p[lol][j] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k2++;
                    lm = 0;
                  } else {
                    int lm = 0;
                    for (int lol = j; lol <= s; lol++)
                      if (p[i][lol] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k1++;
                    lm = 0;
                    for (int lol = i; lol <= k; lol++)
                      if (p[lol][s] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k1++;
                    lm = 0;
                    for (int lol = j; lol <= s; lol++)
                      if (p[k][lol] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k2++;
                    lm = 0;
                    for (int lol = i; lol <= k; lol++)
                      if (p[lol][j] != 'B') {
                        lm = 1;
                        break;
                      }
                    if (lm == 0) k2++;
                    lm = 0;
                  }
                  if (k1 != 2 && k2 != 2) {
                    inf = 1;
                    break;
                  }
                }
              if (inf) break;
            }
          }
      }
    }
    if (inf == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
