#include <bits/stdc++.h>
using namespace std;
const int maxn = 20, maxal = 26, maxmask = 1 << maxn;
int dp[maxmask], a[maxn][maxn], cost[maxn], MAX[maxal], COS[maxal], MASK[maxal];
vector<pair<int, int> > chng;
string s[maxn];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  memset(cost, 63, sizeof cost);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      ((cost[i]) = min((cost[i]), (a[i][j])));
    }
  for (int j = 0; j < m; j++) {
    memset(MAX, 0, sizeof MAX);
    memset(COS, 0, sizeof COS);
    memset(MASK, 0, sizeof MASK);
    for (int i = 0; i < n; i++) {
      ((MAX[s[i][j] - 'a']) = max((MAX[s[i][j] - 'a']), (a[i][j])));
      COS[s[i][j] - 'a'] += a[i][j];
      MASK[s[i][j] - 'a'] += 1 << i;
    }
    for (int i = 0; i < 26; i++)
      if (MASK[i]) chng.push_back(make_pair(MASK[i], COS[i] - MAX[i]));
  }
  memset(dp, 63, sizeof dp);
  dp[0] = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    for (auto e : chng)
      ((dp[mask | e.first]) = min((dp[mask | e.first]), (dp[mask] + e.second)));
    for (int i = 0; i < n; i++)
      ((dp[mask | (1 << i)]) =
           min((dp[mask | (1 << i)]), (dp[mask] + cost[i])));
  }
  cout << dp[(1 << n) - 1] << '\n';
  return 0;
}
