#include <bits/stdc++.h>
using namespace std;
int Num;
char CH[20];
const int inf = 1 << 29;
inline long long read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void P(int x) {
  Num = 0;
  if (!x) {
    putchar('0');
    puts("");
    return;
  }
  while (x > 0) CH[++Num] = x % 10, x /= 10;
  while (Num) putchar(CH[Num--] + 48);
  puts("");
}
int a[40][40];
string s[40];
int d[1 << 20];
int p[40];
int main() {
  int n = read(), m = read();
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int j = 0; j < 1 << n; j++) d[j] = inf;
  d[0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 26; j++) p[j] = 0;
    for (int j = 0; j < n; j++) p[s[j][i] - 'a'] |= 1 << j;
    for (int j = 0; j < 26; j++) {
      int t = 0, mx = 0;
      for (int k = 0; k < n; k++) {
        if (p[j] >> k & 1) {
          for (int l = 0; l < 1 << n; l++)
            d[l | (1 << k)] = min(d[l | (1 << k)], d[l] + a[k][i]);
          t += a[k][i];
          mx = max(mx, a[k][i]);
        }
      }
      for (int l = 0; l < 1 << n; l++)
        d[l | p[j]] = min(d[l | p[j]], d[l] + t - mx);
    }
  }
  cout << d[(1 << n) - 1] << endl;
  return 0;
}
