#include <bits/stdc++.h>
using namespace std;
char str[1005];
int tot = 0, ch[100005][27];
int n;
int f[100005], q[100005];
bool flag[100005];
int mark[100005];
long long L;
int getsum(char ch) { return ch - 'a'; }
int a[10001];
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
void Work() {
  int Root = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    int len = (int)strlen(str);
    Root = 0;
    for (int j = 0; j < len; j++) {
      int get = getsum(str[j]);
      if (!ch[Root][get]) {
        ++tot;
        memset(ch[tot], 0, sizeof(ch[tot]));
        flag[tot] = 0;
        f[tot] = 0;
        ch[Root][get] = tot;
      }
      Root = ch[Root][get];
    }
    flag[Root] = true;
    mark[Root] += a[i];
  }
}
struct mat {
  long long a[204][204];
  int N, M;
};
mat operator*(const mat& p1, const mat& p2) {
  mat q;
  q.N = p1.N, q.M = p2.M;
  for (int i = 1; i <= p1.N; i++)
    for (int j = 1; j <= p2.M; j++) q.a[i][j] = -1;
  for (int k = 1; k <= p1.M; k++)
    for (int i = 1; i <= p1.N; i++)
      for (int j = 1; j <= p2.M; j++) {
        if (p1.a[i][k] == -1 || p2.a[k][j] == -1) continue;
        q.a[i][j] = max(q.a[i][j], p1.a[i][k] + p2.a[k][j]);
      }
  return q;
}
int main() {
  mat sum, v;
  scanf("%d %I64d", &n, &L);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  Work();
  int h = 0, t = 0;
  for (int i = 0; i < 26; i++)
    if (ch[0][i]) q[++t] = ch[0][i];
  while (h < t) {
    int k = q[++h];
    for (int i = 0; i < 26; i++) {
      if (!ch[k][i]) {
        ch[k][i] = ch[f[k]][i];
        continue;
      }
      int j = f[k];
      while (j && !ch[j][i]) j = f[j];
      q[++t] = ch[k][i];
      f[ch[k][i]] = ch[j][i];
      flag[ch[k][i]] |= flag[ch[j][i]];
      mark[ch[k][i]] += mark[ch[j][i]];
    }
  }
  for (int i = 1; i <= tot + 1; i++)
    for (int j = 1; j <= tot + 1; j++) v.a[i][j] = -1;
  v.a[1][1] = 0;
  for (int j = 0; j <= tot; j++) {
    for (int k = 0; k < 26; k++) {
      int tmp = ch[j][k];
      if (flag[tmp])
        v.a[j + 1][tmp + 1] = max(v.a[j + 1][tmp + 1], (long long)mark[tmp]);
      else
        v.a[j + 1][tmp + 1] = 0;
    }
  }
  v.N = v.M = tot + 1;
  mat ans;
  ans.N = 1, ans.M = tot + 1;
  ans.a[1][1] = 0;
  for (int i = 2; i <= tot + 1; i++) ans.a[1][i] = -1;
  for (; L; L >>= 1) {
    if (L & 1) ans = ans * v;
    v = v * v;
  }
  long long Ans = 0;
  for (int i = 1; i <= tot + 1; i++) Ans = max(Ans, ans.a[1][i]);
  printf("%I64d\n", Ans);
  return 0;
}
