func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int point, w;   } p[30][30];   int n, m;   int s[30][30], w[30][30], Min[30], f[3000000];   int Get() {     char c = getchar();     while (!isalpha(c)) c = getchar();     return c;   }   void init(int x, int y) {     int t1 = 0, t2 = 0, mx = 0;     for (int i = 1; i <= n; i++)       if (s[i][y] == s[x][y]) {         t1 |= 1 << (i - 1);         t2 += w[i][y];         mx = max(mx, w[i][y]);       }     p[x][y] = (node){t1, t2 - mx};   }   int Getlow(int x) {     int ss[200];     int num = 0;     if (x == 0) return 1;     while (x) {       ss[++num] = x % 2;       x /= 2;     }     ss[++num] = 0;     for (int i = 1; i <= num; i++)       if (ss[i] == 0) return i;   }   int main() {     for (int i = 1; i <= 29; i++) Min[i] = 19240012;     for (int i = 1; i <= 3000000 - 1; i++) f[i] = 30000000;     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) s[i][j] = Get();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> w[i][j];         Min[i] = min(Min[i], w[i][j]);       }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) init(i, j);     f[0] = 0;     for (int i = 0; i < (1 << n); i++) {       int p_ = Getlow(i);       f[i | (1 << (p_ - 1))] = min(f[i | (1 << (p_ - 1))], f[i] + Min[p_]);       for (int j = 1; j <= m; j++)         f[i | p[p_][j].point] = min(f[i | p[p_][j].point], f[i] + p[p_][j].w);     }     cout << f[(1 << n) - 1] << endl;     return 0;   }   