func_code_string: #include <bits/stdc++.h>   using namespace std;   char ff[1005][1005];   int main() {     int t;     scanf( %d , &t);     for (int i = 0; i < t; i++) {       int zz[1005];       int n, m, x, y;       int ww = 0;       int w = 0;       scanf( %d%d%d%d , &n, &m, &x, &y);       for (int j = 1; j <= n; j++) {         char f[1005];         scanf( %s , f);         memset(zz, 0, sizeof(zz));         for (int z = 0; z < strlen(f); z++) {           ff[j][z + 1] = f[z];           if (ff[j][z + 1] == ff[j][z] && ff[j][z] ==  .  && zz[z + 1] == 0 &&               zz[z] == 0) {             ww++;             zz[z + 1] = 1;             zz[z] = 1;           }           if (ff[j][z + 1] ==  . ) w++;         }       }       if (y >= 2 * x) {         printf( %d n , x * w);       } else         printf( %d n , ww * y + x * (w - ww * 2));     }   }   