#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class _T>
inline _T low(_T n) {
  return n & (-n);
}
template <class _T>
inline void swapp(_T &x, _T &y) {
  _T t;
  t = x, x = y, y = t;
}
template <class _T>
inline _T minn(_T i, _T j) {
  return i > j ? j : i;
}
template <class _T>
inline _T maxx(_T i, _T j) {
  return i > j ? i : j;
}
template <class _T>
inline _T gcd(_T b, _T c) {
  return b && c ? (c ? gcd(c, b % c) : b) : b | c;
}
template <class _T>
inline _T abss(_T b) {
  return b > 0 ? b : -b;
}
char str[25][25];
int v[25][25];
int tmp[26], t[26], tv[26], tvsum[26];
int value[25], l = 0;
pair<int, int> a[1000];
int dp[1050000];
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", str[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) scanf("%d", &v[i][j]);
  for (i = 0; i < n; i++) value[i] = 1888888888;
  for (i = 0; i < m; i++) {
    memset(tmp, 0, sizeof(tmp));
    memset(t, 0, sizeof(t));
    memset(tv, 0, sizeof(tv));
    memset(tvsum, 0, sizeof(tvsum));
    for (j = 0; j < n; j++) tmp[str[j][i] - 'a']++;
    for (j = 0; j < n; j++) {
      if (tmp[str[j][i] - 'a'] > 1) {
        value[j] = minn(value[j], v[j][i]);
        t[str[j][i] - 'a'] |= 1 << j;
        tv[str[j][i] - 'a'] = maxx(tv[str[j][i] - 'a'], v[j][i]);
        tvsum[str[j][i] - 'a'] += v[j][i];
      } else
        value[j] = 0;
    }
    for (j = 0; j < 26; j++)
      if (tmp[j] > 1) {
        a[l++] = make_pair(t[j], tvsum[j] - tv[j]);
      }
  }
  for (i = 0; i < n; i++) {
    a[l++] = make_pair(1 << i, value[i]);
  }
  for (i = 0; i < (1 << n); i++) {
    dp[i] = 1888888888;
  }
  dp[0] = 0;
  int s = 0;
  for (i = 0; i < l; i++) {
    for (j = s; j >= 0; j--) {
      if (dp[j] < 1888888888 && dp[j | a[i].first] > dp[j] + a[i].second) {
        dp[j | a[i].first] = dp[j] + a[i].second;
        s = maxx(s, j | a[i].first);
      }
    }
  }
  printf("%d\n", dp[(1 << n) - 1]);
  return 0;
}
