#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mx = 1000;
const int N = 20;
const int MOD = 1e9 + 7;
int n, m, a[N][N], mask1[N][26], b[N], p[N][26], c[N][26], dp[1 << N];
string s[N];
int main() {
  cin >> n >> m;
  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 i = 0; i < n; i++) {
    b[i] = a[i][0];
    for (int j = 1; j < m; j++) b[i] = min(b[i], a[i][j]);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) mask1[j][s[i][j] - 'a'] |= 1 << i;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      c[j][s[i][j] - 'a'] += a[i][j];
      p[j][s[i][j] - 'a'] = max(p[j][s[i][j] - 'a'], a[i][j]);
    }
  for (int mask = 1; mask < (1 << n); mask++) {
    int bit = -1;
    for (int j = 0; j < n; j++)
      if (mask & (1 << j)) {
        bit = j;
        break;
      }
    dp[mask] = inf;
    for (int i = 0; i < n; i++)
      if (mask & (1 << i)) dp[mask] = min(dp[mask], dp[mask ^ (1 << i)] + b[i]);
    for (int j = 0; j < m; j++)
      dp[mask] =
          min(dp[mask], dp[mask ^ (mask & mask1[j][s[bit][j] - 'a'])] +
                            c[j][s[bit][j] - 'a'] - p[j][s[bit][j] - 'a']);
  }
  cout << dp[(1 << n) - 1];
  return 0;
}
