#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = (int)1e9;
string s[22];
int sum[22][33];
int sub[22][33];
int ma[22][33];
int dp[1 << 20];
vector<pair<int, int> > val[22];
int a[22][22];
int A[22];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    A[i] = inf;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      A[i] = min(A[i], a[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      s[i][j] -= 'a';
      sum[j][s[i][j]] += a[i][j];
      ma[j][s[i][j]] = max(ma[j][s[i][j]], a[i][j]);
      sub[j][s[i][j]] |= (1 << i);
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 26; j++) {
      sum[i][j] -= ma[i][j];
      for (int k = 0; k < n; k++)
        if (sub[i][j] & (1 << k)) {
          val[k].push_back(make_pair(sub[i][j], sum[i][j]));
        }
    }
  }
  for (int mask = 0; mask < (1 << n); mask++) {
    dp[mask] = inf;
  }
  dp[0] = 0;
  for (int mask = 0; mask < (1 << n) - 1; mask++) {
    int low = 0;
    while (mask & (1 << low)) low++;
    dp[mask | (1 << low)] = min(dp[mask | (1 << low)], dp[mask] + A[low]);
    for (int i = 0; i < (int)(val[low]).size(); i++) {
      dp[mask | val[low][i].first] =
          min(dp[mask | val[low][i].first], dp[mask] + val[low][i].second);
    }
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}
