#include <bits/stdc++.h>
using namespace std;
const int MAX = 0x3f3f3f3f;
int dp[1 << 20];
string s[20];
int N, M;
int a[22][22];
int lowzero(int st) {
  for (int i = 0; i < N; i++) {
    if (st & (1 << i)) {
      continue;
    }
    return i;
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> a[i][j];
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for (int st = 0; st < (1 << N); st++) {
    if (dp[st] == MAX) continue;
    int t = lowzero(st);
    for (int j = 0; j < M; j++) {
      dp[st | (1 << t)] = min(dp[st | (1 << t)], dp[st] + a[t][j]);
      int tempst = 0, tempsum = 0, tempmax = 0;
      for (int i = 0; i < N; i++) {
        if (s[i][j] == s[t][j]) {
          tempst |= (1 << i);
          tempsum += a[i][j];
          tempmax = max(tempmax, a[i][j]);
        }
      }
      dp[st | tempst] = min(dp[st | tempst], dp[st] + tempsum - tempmax);
    }
  }
  cout << dp[(1 << N) - 1] << endl;
  return 0;
}
