#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, MAXN = 20 + 10;
int dp[1 << 20];
int a[MAXN][MAXN], cost[MAXN][MAXN], to[MAXN][MAXN];
char s[MAXN][MAXN];
int main() {
  int n, m;
  while (~scanf("%d %d%*c", &n, &m)) {
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) scanf("%d%*c", &a[i][j]);
    }
    memset(to, 0, sizeof(to));
    for (int j = 0; j < m; j++) {
      for (int i = 0; i < n; i++) {
        int mx = 0, sum = 0;
        for (int k = 0; k < n; k++) {
          if (s[i][j] == s[k][j]) {
            to[i][j] |= 1 << k;
            mx = max(mx, a[k][j]);
            sum += a[k][j];
          }
        }
        cost[i][j] = sum - mx;
      }
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    int ALL = (1 << n) - 1;
    for (int s = 0; s < ALL; s++) {
      for (int i = 0; i < n; i++) {
        if (0 == (s & (1 << i))) {
          for (int j = 0; j < m; j++) {
            dp[s | (1 << i)] = min(dp[s | (1 << i)], dp[s] + a[i][j]);
            dp[s | to[i][j]] = min(dp[s | to[i][j]], dp[s] + cost[i][j]);
          }
          break;
        }
      }
    }
    printf("%d\n", dp[ALL]);
  }
  return 0;
}
