func_code_string: #include <bits/stdc++.h>   using namespace std;   bool ok1, ok2, ok3, ok4, p1, p2;   int n, m, maxx, minx, maxy, miny;   string a[4002];   int main() {     cin >> n >> m;     minx = miny = 1000000;     maxx = maxy = -1000000;     for (int i = 0; i < n; ++i) {       cin >> a[i];       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  w ) {           if (i > maxx) maxx = i;           if (i < minx) minx = i;           if (j > maxy) maxy = j;           if (j < miny) miny = j;         }       }     }     if (maxx == -1000000) return cout << -1, 0;     ok1 = ok2 = ok3 = ok4 = true;     p1 = p2 = false;     for (int j = 0; j < m; ++j) {       if (a[maxx][j] ==  w  && j != maxy && j != miny) ok1 = false;     }     for (int j = 0; j < m; ++j) {       if (a[minx][j] ==  w  && j != maxy && j != miny) ok2 = false;     }     if (minx == maxx && !ok1) {       ok1 = ok2 = true;       p1 = true;     }     for (int i = 0; i < n; ++i) {       if (a[i][maxy] ==  w  && i != maxx && i != minx) ok3 = false;     }     for (int i = 0; i < n; ++i) {       if (a[i][miny] ==  w  && i != maxx && i != minx) ok4 = false;     }     if (miny == maxy && !ok3) {       ok3 = ok4 = true;       p2 = true;     }     if (maxx - minx > maxy - miny) {       if (ok3) {         int oll = maxx - minx;         int y = maxy;         maxy = miny + oll;         if (maxy >= m && !p2) {           if (!ok4) return cout << -1, 0;           while (maxy >= m) {             maxy--;             miny--;           }           if (miny < 0) return cout << -1, 0;         } else if (maxy >= m) {           miny = y - oll;           maxy = y;           if (miny < 0 || !ok4) return cout << -1, 0;         }       } else if (ok4) {         miny = maxy - maxx + minx;         if (miny < 0) return cout << -1, 0;       } else         return cout << -1, 0;     } else if (maxx - minx < maxy - miny) {       if (ok1) {         int oll = maxy - miny;         int x = maxx;         maxx = minx + oll;         if (maxx >= n && !p1) {           if (!ok2) return cout << -1, 0;           while (maxx >= n) {             maxx--;             minx--;           }           if (minx < 0) return cout << -1, 0;         } else if (maxx >= n) {           minx = x - oll;           maxx = x;           if (minx < 0 || !ok2) return cout << -1, 0;         }       } else if (ok2) {         minx = maxx - maxy + miny;         if (minx < 0) return cout << -1, 0;       } else         return cout << -1, 0;     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  w  && i != minx && i != maxx && j != miny && j != maxy)           return cout << -1, 0;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  w )           cout <<  w ;         else if (((i == minx || i == maxx) && (miny <= j && j <= maxy)) ||                  ((j == miny || j == maxy) && (minx <= i && i <= maxx)))           cout <<  + ;         else           cout <<  . ;       }       cout << endl;     }   }   