#include <bits/stdc++.h>
using namespace std;
int n, m, dp[1 << 20], a[20][20], c[20][26], v[20][26], mx[20][26], mn[20];
char s[20][26];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) {
    mn[i] = 1e9;
    for (int j = 0; j < m; j++) {
      scanf("%d", a[i] + j);
      mn[i] = min(mn[i], a[i][j]);
      int x = s[i][j] - 'a';
      mx[j][x] = max(mx[j][x], a[i][j]);
      v[j][x] ^= (1 << i);
      c[j][x] += a[i][j];
    }
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < 26; j++) c[i][j] -= mx[i][j];
  dp[0] = 0;
  int k = (1 << n);
  for (int i = 1; i < k; i++) {
    int x = __builtin_ctz(i);
    dp[i] = dp[i ^ (1 << x)] + mn[x];
    for (int j = 0; j < m; j++) {
      int y = s[x][j] - 'a';
      dp[i] = min(dp[i], dp[(i | v[j][y]) ^ v[j][y]] + c[j][y]);
    }
  }
  printf("%d\n", dp[k - 1]);
}
