#include <bits/stdc++.h>
using namespace std;
const int N = 20;
const int leng = 300;
string s[N];
int cost[N][leng], c[N][leng], sv[N][leng], a[N][leng];
int d[1 << N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) cin >> s[i];
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++) cin >> a[i][j];
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(m); j++) {
      int curv = 0;
      for (int k = 0; k < int(n); k++) {
        if (s[i][j] == s[k][j]) {
          sv[i][j] |= (1 << k);
          c[i][j] += a[k][j];
          curv = max(curv, a[k][j]);
        }
      }
      c[i][j] -= curv;
    }
  }
  for (int i = 0; i < int(1 << n); i++) d[i] = 1000000000;
  d[0] = 0;
  for (int mask = 0; mask < int(1 << n); mask++) {
    if (mask == 0) continue;
    int lowbit = -1;
    for (int i = 0; i < int(n); i++) {
      if ((mask >> i) & 1) {
        lowbit = i;
        break;
      }
    }
    for (int i = 0; i < int(m); i++) {
      d[mask] = min(d[mask], d[mask & (mask ^ sv[lowbit][i])] + c[lowbit][i]);
      d[mask] = min(d[mask], d[mask ^ (1 << lowbit)] + a[lowbit][i]);
    }
  }
  printf("%d\n", d[(1 << n) - 1]);
}
