#include <bits/stdc++.h>
using namespace std;
int n, mz;
char tmp;
bool t[51][51];
bool m[51][51];
int mel, skm;
bool atr;
bool state;
void apstaig(int x, int y) {
  int i, j, z;
  for (i = x; i <= mz; i++) {
    if (t[i][y] == false)
      break;
    else {
      m[i][y] = !state;
      skm++;
      j = y - 1;
      while (j > 0) {
        if (t[i][j] == false)
          break;
        else {
          if (m[i][j] == state) {
            m[i][j] = !state;
            skm++;
          }
        }
        j--;
      }
      j = y + 1;
      while (j <= n) {
        if (t[i][j] == false)
          break;
        else {
          if (m[i][j] == state) {
            m[i][j] = !state;
            skm++;
          }
        }
        j++;
      }
    }
  }
  for (i = x - 1; i > 0; i--) {
    if (t[i][y] == false)
      break;
    else {
      m[i][y] = !state;
      skm++;
      j = y - 1;
      while (j > 0) {
        if (t[i][j] == false)
          break;
        else {
          if (m[i][j] == state) {
            m[i][j] = !state;
            skm++;
          }
        }
        j--;
      }
      j = y + 1;
      while (j <= n) {
        if (t[i][j] == false)
          break;
        else {
          if (m[i][j] == state) {
            m[i][j] = !state;
            skm++;
          }
        }
        j++;
      }
    }
  }
  for (i = y - 1; i > 0; i--) {
    if (t[x][i] == false)
      break;
    else {
      if (m[x][i] == state) {
        m[j][i] = !state;
        skm++;
      }
      j = x - 1;
      while (j > 0) {
        if (t[j][i] == false)
          break;
        else {
          if (m[j][i] == state) {
            m[j][i] = !state;
            skm++;
          }
        }
        j--;
      }
      j = x + 1;
      while (j <= mz) {
        if (t[j][i] == false)
          break;
        else {
          if (m[j][i] == state) {
            m[j][i] = !state;
            skm++;
          }
        }
        j++;
      }
    }
  }
  for (i = y + 1; i <= n; i++) {
    if (t[x][i] == false)
      break;
    else {
      if (m[x][i] == state) {
        m[j][i] = !state;
        skm++;
      }
      j = x - 1;
      while (j > 0) {
        if (t[j][i] == false)
          break;
        else {
          if (m[j][i] == state) {
            m[j][i] = !state;
            skm++;
          }
        }
        j--;
      }
      j = x + 1;
      while (j <= mz) {
        if (t[j][i] == false)
          break;
        else {
          if (m[j][i] == state) {
            m[j][i] = !state;
            skm++;
          }
        }
        j++;
      }
    }
  }
}
int main() {
  int i, j;
  cin >> n >> mz;
  mel = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= mz; j++) {
      cin >> tmp;
      if (tmp == 'B') {
        t[j][i] = true;
        mel++;
        m[j][i] = false;
      } else
        t[j][i] = false;
    }
  atr = true;
  state = false;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= mz; j++) {
      if (t[j][i] == true) {
        skm = 0;
        apstaig(j, i);
        if (skm != mel) {
          atr = false;
          break;
        }
        state = !state;
      }
    }
  if (atr)
    cout << "YES";
  else
    cout << "NO";
}
