#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long dp[1 << 21], ditu[25][25], vis[25][25], st[25][25];
char s[25][25];
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      scanf("%lld", &ditu[i][j]);
    }
  }
  long long maxst = (1 << n) - 1;
  for (long long i = 0; i < n; i++) {
    for (long long k = 0; k < m; k++) {
      long long maxn = 0;
      for (long long j = 0; j < n; j++) {
        if (s[i][k] != s[j][k]) {
          continue;
        }
        vis[i][k] += ditu[j][k];
        maxn = max(ditu[j][k], maxn);
        st[i][k] |= 1 << j;
      }
      vis[i][k] -= maxn;
    }
  }
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  dp[0] = 0;
  for (long long i = 0; i < maxst; i++) {
    for (long long j = 0;; j++) {
      if (!((i >> j) & 1)) {
        long long cnt = 1 << j;
        for (long long k = 0; k < m; k++) {
          long long opt = st[j][k];
          dp[i | cnt] = min(dp[i | cnt], dp[i] + ditu[j][k]);
          dp[i | opt] = min(dp[i | opt], dp[i] + vis[j][k]);
        }
        break;
      }
    }
  }
  printf("%lld\n", dp[maxst]);
  return 0;
}
