func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class _T>   inline _T sqr(const _T& x) {     return x * x;   }   template <class _T>   inline string tostr(const _T& a) {     ostringstream os(  );     os << a;     return os.str();   }   const long double PI = 3.1415926535897932384626433832795;   const long double EPS = 1e-11;   const int dx[4] = {0, -1, 0, 1};   const int dy[4] = {-1, 0, 1, 0};   int n, m, k;   char a[1024][1024];   char a0[1024][1024];   int c[1024][1024];   bool u[1024][1024];   bool u2[12];   void dfs(int x, int y, int px, int py) {     u[x][y] = true;     int cnt = 0;     int t[4] = {0, 1, 2, 3};     for (int i = 0; i < (int)(4); i++) {       swap(t[i], t[rand() % 4]);     }     for (int l1 = 0; l1 < (int)(4); l1++) {       int l = t[l1];       int xn = x + dx[l];       int yn = y + dy[l];       if (xn < 0 || xn >= n || yn < 0 || yn >= m || u[xn][yn] || a[xn][yn] ==  # )         continue;       dfs(xn, yn, x, y);       if (c[xn][yn] == -1) cnt++;     }     if (cnt) {       for (int l = 0; l < (int)(4); l++) {         int xn = x + dx[l];         int yn = y + dy[l];         if (xn < 0 || xn >= n || yn < 0 || yn >= m || a[xn][yn] ==  #  ||             c[xn][yn] != -1 || (xn == px && yn == py))           continue;         c[xn][yn] = k;       }       c[x][y] = k++;     }   }   void dfs2(int x, int y, int col) {     u[x][y] = true;     for (int l = 0; l < (int)(4); l++) {       int xn = x + dx[l];       int yn = y + dy[l];       if (xn < 0 || xn >= n || yn < 0 || yn >= m || a[xn][yn] ==  # ) continue;       if (c[xn][yn] == col) {         if (!u[xn][yn]) dfs2(xn, yn, col);       } else if (a[xn][yn] !=  . ) {         u2[a[xn][yn] -  0 ] = true;       }     }   }   void dfs3(int x, int y, int col, int nc) {     a[x][y] =  0  + nc;     c[x][y] = -1;     for (int l = 0; l < (int)(4); l++) {       int xn = x + dx[l];       int yn = y + dy[l];       if (xn < 0 || xn >= n || yn < 0 || yn >= m || a[xn][yn] ==  # ) continue;       if (c[xn][yn] == col) {         dfs3(xn, yn, col, nc);       }     }   }   int check(int x, int y) {     int ans = 1;     u[x][y] = true;     for (int l = 0; l < (int)(4); l++) {       int xn = x + dx[l];       int yn = y + dy[l];       if (xn < 0 || xn >= n || yn < 0 || yn >= m || u[xn][yn] ||           a[xn][yn] ==  #  || a[xn][yn] != a[x][y])         continue;       ans += check(xn, yn);     }     return ans;   }   int check2(int x, int y) {     int ans = 1;     u[x][y] = true;     for (int l = 0; l < (int)(4); l++) {       int xn = x + dx[l];       int yn = y + dy[l];       if (xn < 0 || xn >= n || yn < 0 || yn >= m || u[xn][yn] ||           a[xn][yn] ==  #  || c[xn][yn] != c[x][y])         continue;       ans += check2(xn, yn);     }     return ans;   }   int main() {     cout << setiosflags(ios::fixed) << setprecision(10);     srand(672465);     memset(c, 0xff, sizeof(c));     scanf( %d%d , &n, &m);     memset((a), 0, sizeof(a));     for (int i = 0; i < (int)(n); i++) {       scanf( %s , a[i]);       a[i][m] =   0 ;     }     memcpy(a0, a, sizeof(a));     memset((u), 0, sizeof(u));     k = 0;     for (int i = 0; i < (int)(n); i++) {       for (int j = 0; j < (int)(m); j++) {         if (!u[i][j] && a[i][j] !=  # ) {           dfs(i, j, -1, -1);           if (c[i][j] == -1) {             bool bb = true;             for (int l = 0; l < (int)(4); l++) {               int xn = i + dx[l];               int yn = j + dy[l];               if (xn < 0 || xn >= n || yn < 0 || yn >= m || a[xn][yn] ==  # )                 continue;               if (c[xn][yn] != -1) {                 c[i][j] = c[xn][yn];                 bb = false;                 break;               }             }             if (bb) {               puts( -1 );               return 0;             }           }         }       }     }     memset((u), 0, sizeof(u));     for (int i = 0; i < (int)(n); i++) {       for (int j = 0; j < (int)(m); j++) {         if (!u[i][j] && a[i][j] !=  # ) {           int cnt = check2(i, j);           if (cnt < 2 || cnt > 5) {           }         }       }     }     memset((u), 0, sizeof(u));     for (int i = 0; i < (int)(n); i++) {       for (int j = 0; j < (int)(m); j++) {         if (a[i][j] ==  . ) {           memset((u2), 0, sizeof(u2));           dfs2(i, j, c[i][j]);           bool bbb = true;           for (int t = 0; t < (int)(12); t++) {             if (!u2[t]) {               dfs3(i, j, c[i][j], t);               bbb = false;               break;             }           }           if (bbb) return 1;         }       }     }     memset((u), 0, sizeof(u));     for (int i = 0; i < (int)(n); i++) {       for (int j = 0; j < (int)(m); j++) {         if (a0[i][j] ==  # ) {           if (a[i][j] !=  # ) cout <<  Botwa ! 1 !  << endl;         } else {           if (!isdigit(a[i][j])) cout <<  Botwa ! 2 !  << endl;         }         if (a[i][j] !=  #  && !isdigit(a[i][j]))           cout <<  a[  << i <<  ][  << j <<  ] =    << a[i][j] <<     << endl;         if (!u[i][j] && a[i][j] !=  # ) {           int cnt = check(i, j);           if (cnt < 2 || cnt > 5) {             for (int ii = (-4); ii <= (int)(4); ii++) {               for (int jj = (-4); jj <= (int)(4); jj++) {                 if (i + ii >= 0 && j + jj >= 0) cout << a[i + ii][j + jj];               }               if (i + ii >= 0) cout << endl;             }             cout <<  ?   << cnt <<     << a[i][j] << endl;           }         }       }     }     for (int i = 0; i < (int)(n); i++) {       puts(a[i]);     }     return 0;   }   