func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int vis[1005][1005];   char a[1005][1005];   pair<pair<long long int, long long int>, long long int> fuck[1005][1005];   long long int dfs(long long int i, long long int j,                     pair<long long int, long long int> par) {     vis[i][j] = 1;     long long int ret = 1;     if (a[i + 1][j] ==  .  && vis[i + 1][j] == 0) ret += dfs(i + 1, j, par);     if (a[i - 1][j] ==  .  && vis[i - 1][j] == 0) ret += dfs(i - 1, j, par);     if (a[i][j + 1] ==  .  && vis[i][j + 1] == 0) ret += dfs(i, j + 1, par);     if (a[i][j - 1] ==  .  && vis[i][j - 1] == 0) ret += dfs(i, j - 1, par);     fuck[i][j] = make_pair(par, ret);     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       long long int i, j;       for (i = 0; i < 1005; i++) {         for (j = 0; j < 1005; j++) {           vis[i][j] = 0;           a[i][j] =  * ;         }       }       long long int n, m;       cin >> n >> m;       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           cin >> a[i][j];         }       }       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           if (a[i][j] ==  .  && vis[i][j] == 0) {             dfs(i, j, make_pair(i, j));           }         }       }       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           if (a[i][j] ==  . ) {             cout <<  . ;           } else {             map<pair<long long int, long long int>, long long int> ma;             if (a[i + 1][j] ==  . ) {               ma[fuck[i + 1][j].first] =                   fuck[fuck[i + 1][j].first.first][fuck[i + 1][j].first.second]                       .second;             }             if (a[i - 1][j] ==  . ) {               ma[fuck[i - 1][j].first] =                   fuck[fuck[i - 1][j].first.first][fuck[i - 1][j].first.second]                       .second;             }             if (a[i][j + 1] ==  . ) {               ma[fuck[i][j + 1].first] =                   fuck[fuck[i][j + 1].first.first][fuck[i][j + 1].first.second]                       .second;             }             if (a[i][j - 1] ==  . ) {               ma[fuck[i][j - 1].first] =                   fuck[fuck[i][j - 1].first.first][fuck[i][j - 1].first.second]                       .second;             }             long long int ans = 1;             for (auto it : ma) {               ans += it.second;             }             cout << ans % 10;           }         }         cout <<   n ;       }     }     return 0;   }   