#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma comment(linker, "/STACK:26777216")
using namespace std;
const long long MOD = 100000007;
const long long LINF = 1000000097999999903LL;
long long boundz = 10000000001LL;
const int INF = (1 << 29);
int N, M;
char crr[22][22];
int costz[22][1048576];
int arr[22][22];
int ret[1048576];
int matchedMask[22][1048576];
void reset() {
  memset(arr, 0, sizeof(arr));
  memset(crr, 0, sizeof(crr));
  memset(costz, 0, sizeof(costz));
  memset(ret, 0, sizeof(ret));
}
int main() {
  reset();
  scanf("%d %d", &N, &M);
  for (int i = (0); i <= (N - 1); i++) {
    scanf("%s", &crr[i]);
  }
  for (int i = (0); i <= (N - 1); i++) {
    for (int j = (0); j <= (M - 1); j++) {
      scanf("%d", &arr[i][j]);
    }
  }
  int maxColCost = 0;
  for (int i = (0); i <= (N - 1); i++) {
    for (int j = (0); j <= (M - 1); j++) {
      maxColCost = 0;
      int mask = 0;
      for (int k = (0); k <= (N - 1); k++) {
        if (crr[i][j] != crr[k][j]) continue;
        mask |= (1 << k);
        costz[i][j] += arr[k][j];
        maxColCost = max(maxColCost, arr[k][j]);
      }
      costz[i][j] -= maxColCost;
      matchedMask[i][j] = mask;
    }
  }
  int upto = (1 << N) - 1;
  for (int i = (0); i <= (upto); i++) {
    ret[i] = 20000001;
  }
  ret[0] = 0;
  for (int mask = (0); mask <= (upto); mask++) {
    int whom = 0;
    for (int i = (0); i <= (N - 1); i++) {
      if (mask & (1 << i)) {
        whom = i;
        break;
      }
    }
    for (int j = (0); j <= (M - 1); j++) {
      ret[mask] = min(ret[mask], ret[mask & (mask ^ matchedMask[whom][j])] +
                                     costz[whom][j]);
      ret[mask] =
          min(ret[mask], ret[mask & (mask ^ (1 << whom))] + arr[whom][j]);
    }
  }
  printf("%d\n", ret[upto]);
  return 0;
}
