#include <bits/stdc++.h>
using namespace std;
int n, m, a[20][20];
int sch[20][26] = {0}, mch[20][26] = {0}, ich[20][26] = {0};
int dp[(1 << 20)];
string strs[20];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> strs[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      int ch = strs[i][j] - 'a';
      sch[j][ch] += a[i][j];
      mch[j][ch] = max(mch[j][ch], a[i][j]);
      ich[j][ch] |= (1 << i);
    }
  fill(dp, dp + (1 << 20), 100000000);
  dp[0] = 0;
  for (int s = 0; s < (1 << n) - 1; s++) {
    if (dp[s] == 100000000) continue;
    int inds = 0;
    for (; inds < n; inds++)
      if (~s >> inds & 1) break;
    for (int j = 0; j < m; j++) {
      int ch = strs[inds][j] - 'a';
      dp[s | 1 << inds] = min(dp[s | 1 << inds], dp[s] + a[inds][j]);
      dp[s | ich[j][ch]] =
          min(dp[s | ich[j][ch]], dp[s] + sch[j][ch] - mch[j][ch]);
    }
  }
  printf("%d\n", dp[(1 << n) - 1]);
  return 0;
}
