func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   char ch[5200][5200];   int main() {     int top, down, lft, rht;     top = down = -1;     lft = rht = -1;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %s , ch[i]);     }     for (int i = 0; i < n; i++) {       bool flag = false;       for (int j = 0; j < m; j++) {         if (ch[i][j] ==  w ) {           flag = true;           break;         }       }       if (flag) {         top = i;         break;       }     }     for (int i = n - 1; i >= 0; i--) {       bool flag = false;       for (int j = 0; j < m; j++) {         if (ch[i][j] ==  w ) {           flag = true;           break;         }       }       if (flag) {         down = i;         break;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (ch[i][j] ==  w ) {           if (lft == -1 || lft > j) lft = j;           break;         }       }       for (int j = m - 1; j >= 0; j--) {         if (ch[i][j] ==  w ) {           if (rht == -1 || rht < j) rht = j;           break;         }       }     }     bool ok = true;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (ch[i][j] ==  w ) {           if (i != top && i != down && j > lft && j < rht) {             ok = false;             break;           }         }         if (!ok) break;       }       if (!ok) break;     }     if (!ok) {       puts( -1 );       return 0;     }     if (down - top > rht - lft) {       int x = down - top;       int y = rht - lft;       int z = x - y;       bool flag = true;       for (int i = top + 1; i < down; i++)         if (ch[i][lft] ==  w ) flag = false;       if (!flag) {         if (lft == rht) {           if (lft >= z) {             lft -= z;             z = 0;           }         }       } else if (lft >= z) {         lft = lft - z;         z = 0;       } else {         z -= lft;         lft = 0;       }       if (z > 0) {         flag = true;         for (int i = top + 1; i < down; i++)           if (ch[i][rht] ==  w ) flag = false;         if (!flag) {           if (lft == rht) {             if (m - 1 - rht >= z) {               rht += z;               z = 0;             }           }         } else if (m - 1 - rht >= z) {           rht += z;           z = 0;         } else {           z -= m - 1 - rht;           rht = m - 1;         }       }     } else if (rht - lft > down - top) {       int x = down - top;       int y = rht - lft;       int z = y - x;       bool flag = true;       for (int i = lft + 1; i < rht; i++)         if (ch[top][i] ==  w ) flag = false;       if (!flag) {         if (top == down) {           if (top >= z) {             top = top - z;             z = 0;           }         }       } else if (top >= z) {         top = top - z;         z = 0;       } else {         z -= top;         top = 0;       }       if (z > 0) {         flag = true;         for (int i = lft + 1; i < rht; i++)           if (ch[down][i] ==  w ) flag = false;         if (!flag) {           if (top == down) {             if (n - 1 - down >= z) {               down += z;               z = 0;             }           }         } else if (n - 1 - down >= z) {           down += z;           z = 0;         } else {           z -= n - 1 - down;           down = n - 1;         }       }     }     if (down - top == rht - lft) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (ch[i][j] ==  w )             cout << ch[i][j];           else if ((i == top || i == down) && j >= lft && j <= rht)             cout <<  + ;           else if (i >= top && i <= down && (j == lft || j == rht))             cout <<  + ;           else             cout << ch[i][j];         }         cout << endl;       }     } else       puts( -1 );   }   