#include <bits/stdc++.h>
using namespace std;
int n, m, a[22][22], dp[1 << 21], cnt[256][22], upat[256][22], ucost[256][22],
    ucostmin[256][22];
char s[22][22 + 1];
int main() {
  int i, j, k, c;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> a[i][j];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      c = s[i][j];
      cnt[c][j]++;
      upat[c][j] |= (1 << i);
      ucost[c][j] += a[i][j];
      ucostmin[c][j] = max(ucostmin[c][j], a[i][j]);
    }
  for (c = 'a'; c <= 'z'; c++)
    for (j = 0; j < m; j++) ucost[c][j] -= ucostmin[c][j];
  int pat = 0;
  for (i = 0; i < 22; i++)
    for (j = 0; j < (1 << n); j++) dp[j] = (22 * 22 * 1000000 + 2);
  dp[pat] = 0;
  for (j = 0; j < m; j++) {
    for (pat = 0; pat < (1 << n); pat++) {
      for (c = 'a'; c <= 'z'; c++) {
        int pat1 = pat | upat[c][j];
        dp[pat1] = min(dp[pat1], dp[pat] + ucost[c][j]);
      }
    }
    for (pat = 0; pat < (1 << n); pat++) {
      for (i = 0; i < n; i++) {
        int pat1 = pat | (1 << i);
        dp[pat1] = min(dp[pat1], dp[pat] + a[i][j]);
      }
    }
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}
