#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
struct NODE {
  int sta;
  int num;
} nodes[25][25];
int dp[1 << 20], n, m;
int num[25][25];
char str[25][25];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i < n; i++) {
      scanf("%s", str[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        scanf("%d", &num[i][j]);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int max1 = 0;
        for (int k = 0; k < n; k++) {
          if (str[i][j] == str[k][j]) {
            nodes[i][j].sta |= (1 << k);
            nodes[i][j].num += num[k][j];
            max1 = max(max1, num[k][j]);
          }
        }
        nodes[i][j].num -= max1;
      }
    }
    int sta = 1 << n;
    for (int i = 0; i < sta; i++) {
      dp[i] = 99999999;
    }
    dp[0] = 0;
    for (int i = 1; i < sta; i++) {
      int re = i, cnt = 0;
      while (re) {
        if (re & 1) {
          for (int j = 0; j < m; j++) {
            int sta1 = i & (i ^ nodes[cnt][j].sta);
            dp[i] = min(dp[i], dp[sta1] + nodes[cnt][j].num);
            dp[i] = min(dp[i], dp[i ^ (1 << cnt)] + num[cnt][j]);
          }
        }
        re >>= 1;
        cnt++;
      }
    }
    printf("%d\n", dp[sta - 1]);
  }
  return 0;
}
