func_code_string: #include <bits/stdc++.h>   using namespace std;   int maps[1010][1010];   int n;   int dir[8][2] = {{0, 1},  {1, 0}, {0, -1}, {-1, 0},                    {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};   int pre[8][1010][1010];   double sums[8][1010][1010];   void partial() {     for (int i = 0; i < 8; i++) {       for (int j = 0; j < n; j++) {         for (int k = 0; k < n; k++) {           if (j - dir[i][0] < 0 || j - dir[i][0] >= n || k - dir[i][1] < 0 ||               k - dir[i][1] >= n)             for (int x = j, y = k; x >= 0 && x < n && y >= 0 && y < n;                  x += dir[i][0], y += dir[i][1]) {               if (maps[x][y] == 0) {                 pre[i][x][y] = 0;                 sums[i][x][y] = 0;               } else {                 if (x == j && y == k) {                   pre[i][x][y] = 1;                   sums[i][x][y] = log(maps[x][y]);                 } else {                   pre[i][x][y] = pre[i][x - dir[i][0]][y - dir[i][1]] + 1;                   sums[i][x][y] =                       sums[i][x - dir[i][0]][y - dir[i][1]] + log(maps[x][y]);                 }               }             }         }       }     }   }   double maxCross(int x, int y) {     int minN = 1e9, minR = 1e9;     double rot = log(maps[x][y]), norm = log(maps[x][y]);     for (int i = 0; i < 4; i++) {       minN = min(minN, pre[i][x][y]);     }     for (int i = 4; i < 8; i++) {       minR = min(minR, pre[i][x][y]);     }     minN--;     minR--;     for (int i = 0; i < 4; i++) {       int sx = x + (dir[i][0] * minN);       int sy = y + (dir[i][1] * minN);       norm += sums[i][sx][sy] - sums[i][x][y];     }     for (int i = 4; i < 8; i++) {       int sx = x + (dir[i][0] * minR);       int sy = y + (dir[i][1] * minR);       rot += sums[i][sx][sy] - sums[i][x][y];     }     return max(norm, rot);   }   bool isNorm(int x, int y) {     int minN = 1e9, minR = 1e9;     double rot = log(maps[x][y]), norm = log(maps[x][y]);     for (int i = 0; i < 4; i++) {       minN = min(minN, pre[i][x][y]);     }     for (int i = 4; i < 8; i++) {       minR = min(minR, pre[i][x][y]);     }     minN--;     minR--;     for (int i = 0; i < 4; i++) {       int sx = x + (dir[i][0] * minN);       int sy = y + (dir[i][1] * minN);       norm += sums[i][sx][sy] - sums[i][x][y];     }     for (int i = 4; i < 8; i++) {       int sx = x + (dir[i][0] * minR);       int sy = y + (dir[i][1] * minR);       rot += sums[i][sx][sy] - sums[i][x][y];     }     return norm > rot;   }   long long calcMax(int x, int y) {     int minN = 1e9, minR = 1e9;     long long rot = maps[x][y], norm = maps[x][y];     for (int i = 0; i < 4; i++) {       minN = min(minN, pre[i][x][y]);     }     for (int i = 4; i < 8; i++) {       minR = min(minR, pre[i][x][y]);     }     minN--;     minR--;     for (int i = 0; i < 4; i++) {       int sx = x;       int sy = y;       for (int j = 0; j < minN; j++) {         sx += dir[i][0];         sy += dir[i][1];         norm *= maps[sx][sy];         norm %= (long long)1e9 + 7;       }     }     for (int i = 4; i < 8; i++) {       int sx = x;       int sy = y;       for (int j = 0; j < minR; j++) {         sx += dir[i][0];         sy += dir[i][1];         rot *= maps[sx][sy];         rot %= (long long)1e9 + 7;       }     }     return (isNorm(x, y) ? norm : rot);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     ;     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         char ch;         cin >> ch;         maps[i][j] = ch -  0 ;       }     }     partial();     int maxX = 0, maxY = 0;     double maxVal = -1;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (maps[i][j] != 0) {           double temp = maxCross(i, j);           if (temp > maxVal) {             maxVal = temp;             maxX = i;             maxY = j;           }         }       }     }     cout << calcMax(maxX, maxY) << endl;   }   