#include <bits/stdc++.h>
int f[1200000], g[30][30], h[30][30], o[30], p[30], q[30][30];
char c[30][30];
int i, j, k, l, m, n, t, u, v;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) c[i][j] = c[i][j] - 96;
  memset(o, 12, sizeof(o));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &g[i][j]);
      if (g[i][j] < o[i]) o[i] = g[i][j];
    }
  for (i = 1; i <= m; i++)
    for (j = 1; j <= 26; j++) {
      for (k = 1, l = 0, u = 0, v = 0; k <= n; k++)
        if (c[k][i] == j) {
          l = l | (1 << (k - 1));
          u = u + g[k][i];
          if ((!v) || (g[v][i] < g[k][i])) v = k;
        }
      h[i][j] = l, q[i][j] = u - g[v][i];
    }
  for (i = 1; i <= n; i++) p[i] = 1 << (i - 1);
  t = (1 << n) - 1;
  memset(f, 12, sizeof(f));
  f[0] = 0;
  for (i = 1; i <= m; i++) {
    for (k = 1; k <= 26; k++)
      if (h[i][k]) {
        for (j = t; j > 0; j--)
          if (((j | h[i][k]) == j) && (f[j] > f[j - h[i][k]] + q[i][k]))
            f[j] = f[j - h[i][k]] + q[i][k];
        for (j = t; j > 0; j--)
          if (((j | h[i][k]) != j) && (f[j]))
            for (l = t ^ j; l != 0; l = l - (l & (-l)))
              if (f[j] > f[j + (l & (-l))]) f[j] = f[j + (l & (-l))];
      }
  }
  for (k = 1; k <= 20; k++)
    for (j = t; j > 0; j--)
      if ((j & p[k]) && (f[j] > f[j - p[k]] + o[k])) f[j] = f[j - p[k]] + o[k];
  printf("%d", f[(1 << n) - 1]);
  return 0;
}
