#include <bits/stdc++.h>
using namespace std;
char s[25][25];
int a[25][25];
int dp[3000000];
int cheapest[25];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (0); i < int(n); ++i) {
    scanf("%s", s[i]);
  }
  for (int i = (0); i < int(n); ++i) {
    cheapest[i] = 100000000;
    for (int j = (0); j < int(m); ++j) {
      scanf("%d", a[i] + j);
      cheapest[i] = min(cheapest[i], a[i][j]);
    }
  }
  for (int i = (0); i < int(3000000); ++i) dp[i] = 1000000000;
  dp[(1 << n) - 1] = 0;
  for (int j = (0); j < int(m); ++j) {
    vector<int> v[256];
    for (int i = (0); i < int(n); ++i) v[s[i][j]].push_back(i);
    for (int k = (0); k < int(256); ++k) {
      if (v[k].empty()) continue;
      int sum = 0;
      int Max = 0;
      int bit = 0;
      for (int i = (0); i < int(v[k].size()); ++i) {
        bit |= (1 << v[k][i]);
        Max = max(Max, a[v[k][i]][j]);
        sum += a[v[k][i]][j];
      }
      int cost = sum - Max;
      for (int i = 0; i < (1 << n); ++i)
        if (dp[i | bit] + cost < dp[i]) dp[i] = dp[i | bit] + cost;
    }
  }
  int ans = 1000000000;
  for (int i = (0); i < int((1 << n)); ++i) {
    int tot = dp[i];
    for (int j = (0); j < int(n); ++j) {
      if (!(i & (1 << j))) continue;
      tot += cheapest[j];
    }
    ans = min(ans, tot);
  }
  printf("%d\n", ans);
}
