#include <bits/stdc++.h>
using namespace std;
int cost[22][27];
int occ[22][27];
int keep[22][27];
int mem[(1 << 22) + 10];
int N, M;
char str[22][22];
int A[22][22];
int min_cost(int sel) {
  int &val = mem[sel];
  if (val >= 0) return val;
  int i, k;
  val = 0;
  if (sel >= (1 << N) - 1) return 0;
  val = (1e9);
  for (k = 0; k < N; ++k)
    if (!(sel & (1 << k))) break;
  for (i = 0; i < M; ++i) {
    val = min(val, min_cost(sel | occ[i][str[k][i] - 'a']) +
                       cost[i][str[k][i] - 'a'] - keep[i][str[k][i] - 'a']);
    val = min(val, min_cost(sel | (1 << k)) + A[k][i]);
  }
  return val;
}
int main() {
  int i;
  scanf("%d%d", &N, &M);
  for (i = 0; i < N; ++i) {
    scanf("%s", str[i]);
  }
  int j;
  for (i = 0; i < N; ++i) {
    for (j = 0; j < M; ++j) {
      scanf("%d", &A[i][j]);
      cost[j][str[i][j] - 'a'] += A[i][j];
      occ[j][str[i][j] - 'a'] |= (1 << i);
      keep[j][str[i][j] - 'a'] = max(keep[j][str[i][j] - 'a'], A[i][j]);
    }
  }
  memset(mem, -1, sizeof(mem));
  printf("%d\n", min_cost(0));
  return 0;
}
