#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 20;
int a[N][N];
char str[N][N];
int mn[N];
int s[N][N];
int smsk[N][N];
int dp[1 << N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)n; i++) scanf("%s", str[i]);
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < (int)n; i++) {
    mn[i] = a[i][0];
    for (int j = 0; j < (int)m; j++) mn[i] = min(mn[i], a[i][j]);
  }
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)m; j++) {
      int mx = 0;
      int msk = 0;
      for (int i2 = 0; i2 < (int)n; i2++) {
        if (str[i][j] == str[i2][j]) {
          msk |= 1 << i2;
          s[i][j] += a[i2][j];
          mx = max(a[i2][j], mx);
        }
      }
      s[i][j] -= mx;
      smsk[i][j] = msk;
    }
  }
  for (int msk = 1; msk < (int)1 << n; msk++) {
    int rw;
    for (int j = 0; j < (int)n; j++)
      if ((msk >> j) & 1) {
        rw = j;
        break;
      }
    dp[msk] = mn[rw] + dp[msk ^ (1 << rw)];
    for (int j = 0; j < (int)m; j++) {
      dp[msk] = min(dp[msk], s[rw][j] + dp[msk & (~smsk[rw][j])]);
    }
  }
  printf("%d\n", dp[(1 << n) - 1]);
  return 0;
}
