#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, m;
char s[22][22];
int a[22][22];
int cost[22][26], diff[22][26];
int dp[1 << 21];
int low[1 << 21];
int mn[22];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) cin >> s[i];
  for (int i = 0; i < (n); ++i) mn[i] = INF;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) {
      cin >> a[i][j];
      mn[i] = min(mn[i], a[i][j]);
    }
  for (int j = 0; j < (m); ++j)
    for (int c = 0; c < (26); ++c) {
      int sum = 0, mx = 0;
      for (int i = 0; i < (n); ++i)
        if (s[i][j] - 'a' == c) {
          sum += a[i][j], mx = max(mx, a[i][j]), diff[j][c] |= 1 << i;
        }
      cost[j][c] = sum - mx;
    }
  for (int mask = 0; mask < (1 << n); ++mask)
    dp[mask] = INF, low[mask] = (mask & 1 ? low[mask >> 1] + 1 : 0);
  dp[0] = 0;
  for (int mask = 0; mask < (1 << n); ++mask) {
    int i = low[mask];
    dp[mask | (1 << i)] = min(dp[mask | (1 << i)], dp[mask] + mn[i]);
    for (int j = 0; j < (m); ++j)
      dp[mask | diff[j][s[i][j] - 'a']] = min(
          dp[mask | diff[j][s[i][j] - 'a']], dp[mask] + cost[j][s[i][j] - 'a']);
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}
