#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[25][25];
int cost[30][30], val[30][30], p, d[1 << 20], hap[30][30], maxi[30][30];
int main() {
  int i, j, s;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &cost[i][j]);
      val[j][a[i][j] - 'a' + 1] += (1 << i);
      hap[j][a[i][j] - 'a' + 1] += cost[i][j];
      maxi[j][a[i][j] - 'a' + 1] = max(maxi[j][a[i][j] - 'a' + 1], cost[i][j]);
    }
  }
  for (i = 1; i < (1 << n); i++) {
    if (i == (1 << n) - 1) {
      d[i] = 2147483647;
    }
    d[i] = 2147483647;
    for (j = n - 1; j >= 0; j--) {
      if ((1 << j) & i) {
        p = j;
        break;
      }
    }
    for (j = 0; j < m; j++) {
      s = i & val[j][a[p][j] - 'a' + 1];
      if ((i & s) == s) {
        d[i] = min(d[i], d[i ^ s] + hap[j][a[p][j] - 'a' + 1] -
                             maxi[j][a[p][j] - 'a' + 1]);
      }
      d[i] = min(d[i], d[i - (1 << p)] + cost[p][j]);
    }
  }
  printf("%d", d[(1 << n) - 1]);
  return 0;
}
