#include <bits/stdc++.h>
using namespace std;
string str[22];
vector<pair<int, int> > sets[22];
int a[22][22];
int n, m;
vector<int> uniques;
int uniques_arr[22];
int minis[22];
int memo[1 << 20];
vector<pair<int, int> > SETS[22];
int getMask(vector<int> v) {
  int mask = 0;
  for (int u : v) {
    mask |= 1 << u;
  }
  return mask;
}
void makeSets() {
  for (int j = 0; j < m; j++) {
    for (char ch = 'a'; ch <= 'z'; ch++) {
      vector<int> cur;
      for (int i = 0; i < n; i++) {
        if (str[i][j] == ch) {
          cur.push_back(i);
        }
      }
      if (((int)(cur).size()) > 0) {
        int value = 0;
        if (((int)(cur).size()) == 1)
          value = a[cur[0]][j];
        else {
          int maxi = -1;
          int sum = 0;
          for (int u : cur) {
            if (maxi < a[u][j]) maxi = a[u][j];
            sum += a[u][j];
          }
          value = sum - maxi;
        }
        sets[j].push_back({getMask(cur), value});
        for (int u : cur) SETS[u].push_back({getMask(cur), value});
      }
    }
  }
}
vector<int> findUniques() {
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      bool unique = true;
      for (int k = 0; k < n; k++)
        if (i != k) {
          unique &= str[i][j] != str[k][j];
        }
      uniques_arr[i] |= unique;
    }
  }
  vector<int> v;
  for (int i = 0; i < n; i++)
    if (uniques_arr[i]) v.push_back(i);
  return v;
}
int dp(int mask) {
  if (memo[mask] != -1) return memo[mask];
  int &ret = memo[mask];
  int low;
  for (low = 0; (1 << low) <= mask; low++)
    if (mask >> low & 1)
      if (!uniques_arr[low]) break;
  if ((1 << low) > mask) return ret = 0;
  ret = 1e9;
  for (auto t : SETS[low]) {
    int g = t.first & mask;
    ret = min(ret, dp(mask ^ g) + t.second);
  }
  return ret;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> str[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  makeSets();
  uniques = findUniques();
  for (int i = 0; i < n; i++) {
    minis[i] = 1e9;
    for (int j = 0; j < m; j++) {
      minis[i] = min(minis[i], a[i][j]);
    }
    SETS[i].push_back({1 << i, minis[i]});
  }
  memset(memo, -1, sizeof memo);
  cout << dp((1 << n) - 1) << endl;
  return 0;
}
