func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<vector<int>> moves = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};   bool isValid(int a, int b, int x, int y) {     return (a >= 0 && a < x) && (b >= 0 && b < y);   }   bool isPath(int n, int m, vector<string>& mat) {     bool isPossible = false;     int cnt = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (mat[i][j] ==  G ) cnt++;       }     }     if (mat[n - 1][m - 1] ==  #  && cnt > 0) return isPossible;     vector<vector<bool>> vis(n, vector<bool>(m));     queue<pair<int, int>> q;     q.push({n - 1, m - 1});     vis[n - 1][m - 1] = true;     while (!q.empty()) {       pair<int, int> curr = q.front();       q.pop();       if (mat[curr.first][curr.second] ==  G ) {         cnt--;       }       for (int i = 0; i < 4; i++) {         int nx = curr.first + moves[i][0];         int ny = curr.second + moves[i][1];         if (isValid(nx, ny, n, m) && mat[nx][ny] !=  #  && !vis[nx][ny]) {           q.push({nx, ny});           vis[nx][ny] = true;         }       }     }     isPossible = cnt <= 0 ? true : false;     return isPossible;   }   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       vector<string> mat(n);       for (int i = 0; i < n; i++) {         cin >> mat[i];       }       bool isPossible = true;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (mat[i][j] ==  B ) {             for (int k = 0; k < 4; k++) {               int nx = i + moves[k][0];               int ny = j + moves[k][1];               if (isValid(nx, ny, n, m)) {                 if (mat[nx][ny] ==  G ) {                   isPossible = false;                   break;                 } else if (mat[nx][ny] ==  . ) {                   mat[nx][ny] =  # ;                 }               }             }           }           if (!isPossible) break;         }         if (!isPossible) break;       }       if (!isPossible) {         cout <<  No  << endl;       } else {         isPossible = isPath(n, m, mat);         if (!isPossible)           cout <<  No  << endl;         else           cout <<  Yes  << endl;       }     }   }   