#include <bits/stdc++.h>
using namespace std;
string s[100];
int n, m;
int a[100][100];
int d[3000000];
int sv[100][100];
int c[300][300];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < m; j++) {
      int all = 0;
      int cost = 0;
      for (int k = 1; k <= n; k++) {
        if (s[i][j] == s[k][j]) {
          all += a[k][j];
          cost = max(cost, a[k][j]);
          sv[i][j] |= (1 << (k - 1));
        }
      }
      all -= cost;
      c[i][j] = all;
    }
  int M = 1 << (n);
  for (int i = 1; i < M; i++) d[i] = 1000000000;
  for (int mask = 1; mask < M; mask++) {
    for (int i = 1; i <= n; i++)
      if (mask & (1 << (i - 1))) {
        int lowbit = i;
        for (int i = 0; i < m; i++) {
          d[mask] = min(d[mask], a[lowbit][i] + d[mask ^ (1 << (lowbit - 1))]);
          d[mask] =
              min(d[mask], c[lowbit][i] + d[mask & (mask ^ (sv[lowbit][i]))]);
        }
      }
  }
  cout << d[M - 1];
}
