#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
int n, n2, m, dp[(1 << 21) + 5], a[21][21], cnt[26], sum[26], mx[26], b[21][21],
    c[21][21];
char s[21][21];
int main() {
  scanf("%d%d", &n, &m);
  n2 = 1 << n;
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", a[i] + j);
  for (int j = 0; j < m; ++j) {
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));
    memset(mx, 0, sizeof(mx));
    for (int i = 0; i < n; ++i) {
      cnt[s[i][j] - 'a'] |= (1 << i);
      sum[s[i][j] - 'a'] += a[i][j];
      mx[s[i][j] - 'a'] = max(mx[s[i][j] - 'a'], a[i][j]);
    }
    for (int i = 0; i < n; ++i) {
      b[i][j] = sum[s[i][j] - 'a'] - mx[s[i][j] - 'a'];
      c[i][j] = cnt[s[i][j] - 'a'];
    }
  }
  memset(dp, 63, sizeof(dp));
  dp[0] = 0;
  int lw;
  for (int msk = 0; msk < n2; ++msk) {
    for (lw = 0; lw < n; ++lw)
      if (!(msk & 1 << lw)) break;
    for (int j = 0; j < m; ++j) {
      dp[msk | c[lw][j]] = min(dp[msk | c[lw][j]], dp[msk] + b[lw][j]);
      dp[msk | 1 << lw] = min(dp[msk | 1 << lw], dp[msk] + a[lw][j]);
    }
  }
  printf("%d\n", dp[n2 - 1]);
  return 0;
}
