func_code_string: #include <bits/stdc++.h>   using namespace std;   const int dx[4] = {0, 1, -1, 0}, dy[4] = {-1, 0, 0, 1};   int n, m;   char g[60][60];   bool col[60][60][2][4];   bool tmp[60][60][2][4];   bool inrange(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   void solve(int x, int y, int turn, int dir) {     int nx = x + dx[dir], ny = y + dy[dir];     if (inrange(nx, ny) && g[nx][ny] ==  B  && tmp[nx][ny][turn][dir] == false) {       tmp[nx][ny][turn][dir] = tmp[nx][ny][1][dir] = true;       solve(nx, ny, turn, dir);     }     if (turn == 1) return;     for (int i = 0; i < 4; i++) {       if (i == dir) continue;       nx = x + dx[i], ny = y + dy[i];       if (inrange(nx, ny) && g[nx][ny] ==  B  && tmp[nx][ny][1][i] == false) {         tmp[nx][ny][1][i] = true;         solve(nx, ny, 1, i);       }     }     return;   }   bool check() {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (g[i][j] ==  B ) {           bool ok = false;           for (int x = 0; x < 2 && !ok; x++)             for (int y = 0; y < 4 && !ok; y++)               if (tmp[i][j][x][y]) ok = true;           if (!ok) return false;         }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> g[i][j];       }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (g[i][j] ==  B ) {           memset(tmp, false, sizeof(tmp));           for (int k = 0; k < 4; k++)             tmp[i][j][0][k] = tmp[i][j][1][k] = true, solve(i, j, 0, k);           if (!check()) {             cout <<  NO  << endl;             return 0;           }         }     cout <<  YES  << endl;     return 0;   }   