#include <bits/stdc++.h>
using namespace std;
const int N = 20;
const int SCOPE = 26;
int dp[1 << N];
int penalty[N][N];
char strings[N][N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", strings[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &penalty[i][j]);
    }
  }
  int total = (1 << n);
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for (int j = 0; j < m; j++) {
    for (int mask = 0; mask < total; mask++) {
      for (int i = 0; i < n; i++) {
        dp[mask | (1 << i)] =
            min(dp[mask | (1 << i)], dp[mask] + penalty[i][j]);
      }
    }
    for (int ch = 0; ch < SCOPE; ch++) {
      int local_cost = 0, max_cost = 0;
      int cur_mask = 0;
      for (int i = 0; i < n; i++) {
        if (strings[i][j] == ch + 'a') {
          cur_mask |= (1 << i);
          local_cost += penalty[i][j];
          max_cost = max(max_cost, penalty[i][j]);
        }
      }
      if (cur_mask != 0) {
        for (int mask = 0; mask < total; mask++) {
          dp[mask | cur_mask] =
              min(dp[mask | cur_mask], dp[mask] + local_cost - max_cost);
        }
      }
    }
  }
  printf("%d\n", dp[total - 1]);
  return 0;
}
