func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 60;   int n, m;   char s[N][N];   bool vis[N][N];   int tmp;   int dx[] = {-1, 0, 1, 0};   int dy[] = {0, -1, 0, 1};   inline bool in(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   void dfs(int x, int y) {     vis[x][y] = 1;     tmp++;     for (int i = 0; i < 4; ++i) {       int tx = x + dx[i];       int ty = y + dy[i];       if (in(tx, ty) && s[tx][ty] ==  # ) {         if (!vis[tx][ty]) {           dfs(tx, ty);         }       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %s , s[i]);     }     int cnt = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (s[i][j] ==  # ) {           ++cnt;         }       }     }     if (cnt == 1 || cnt == 2) {       printf( -1 n );       return 0;     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (s[i][j] ==  # ) {           s[i][j] =  . ;           memset(vis, 0, sizeof(vis));           for (int a = 0; a < n; ++a) {             for (int b = 0; b < m; ++b) {               if (s[a][b] ==  # ) {                 tmp = 0;                 dfs(a, b);                 if (tmp != cnt - 1) {                   printf( 1 n );                   return 0;                 }                 a = n, b = m;               }             }           }           s[i][j] =  # ;         }       }     }     printf( 2 n );     return 0;   }   