func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 55;   char a[maxn][maxn];   int vis[maxn][maxn];   int n, m;   inline void go(int x, int y) {     if (vis[x][y] == 1) return;     if (a[x][y] !=  # ) return;     vis[x][y] = 1;     go(x - 1, y);     go(x + 1, y);     go(x, y - 1);     go(x, y + 1);   }   inline bool check(int x, int y) {     a[x][y] =  . ;     int sum = 0;     memset(vis, 0, sizeof(vis));     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++)         if (a[i][j] ==  #  && vis[i][j] == 0) {           sum++;           go(i, j);         }     }     a[x][y] =  # ;     return sum > 1;   }   int main() {     cin >> n >> m;     int sum = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         if (a[i][j] ==  # ) sum++;       }     if (sum <= 2) {       cout <<  -1  << endl;       return 0;     }     int ans = 2;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (a[i][j] ==  # )           if (check(i, j)) ans = 1;     cout << ans << endl;     return 0;   }   