#include <bits/stdc++.h>
using namespace std;
int n, m, a[100][100], f[2000000], p;
char s[30][30];
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++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  memset(f, 0x3f, sizeof(f));
  f[0] = 0;
  for (int i = 0; i <= (1 << n) - 2; i++) {
    for (int j = 0; j < n; j++)
      if (!(i & (1 << j))) {
        p = j;
        break;
      }
    for (int j = 0; j < m; j++) {
      int sum = 0, l = 0, mx = 0;
      f[i | (1 << p)] = min(f[i | (1 << p)], f[i] + a[p][j]);
      for (int k = 0; k < n; k++)
        if (s[k][j] == s[p][j]) {
          sum = sum + a[k][j];
          mx = max(mx, a[k][j]);
          l = l | (1 << k);
        }
      f[i | l] = min(f[i | l], f[i] + sum - mx);
    }
  }
  return printf("%d", f[(1 << n) - 1]), 0;
}
