#include <bits/stdc++.h>
using namespace std;
struct matrix {
  long long a[205][205];
};
struct node {
  int ch[26];
};
char st[205][205];
node trie[205];
int last[205];
int val[205];
int fr[205];
int q[205];
int a[205];
matrix mat, unit;
int n, m;
long long l;
int ins(char* st) {
  int i;
  for (i = 0; *st != '\0'; ++st) {
    if (trie[i].ch[*st - 'a'] == 0) trie[i].ch[*st - 'a'] = ++m;
    i = trie[i].ch[*st - 'a'];
  }
  return i;
}
void getnext() {
  int i, h = 1, t = 0, u, v;
  fr[0] = 0;
  for (i = 0; i < 26; ++i)
    if (u = trie[0].ch[i]) {
      fr[u] = last[u] = 0;
      q[++t] = u;
    }
  while (h <= t) {
    for (i = 0; i < 26; ++i) {
      u = trie[q[h]].ch[i];
      if (u == 4) u = 4;
      if (u == 0) {
        trie[q[h]].ch[i] = trie[fr[q[h]]].ch[i];
        continue;
      }
      q[++t] = u;
      v = fr[q[h]];
      while (v && !trie[v].ch[i]) v = fr[v];
      fr[u] = trie[v].ch[i];
      if (val[fr[u]])
        last[u] = fr[u];
      else
        last[u] = last[fr[u]];
    }
    ++h;
  }
}
void buildmatrix() {
  int i, j, k;
  for (i = 1; i <= m; ++i)
    if (last[q[i]]) val[q[i]] += val[last[q[i]]];
  for (i = 0; i <= m; ++i) {
    for (j = 0; j <= m; ++j) {
      mat.a[i][j] = -(1LL << 60);
      unit.a[i][j] = -(1LL << 60);
    }
    unit.a[i][i] = 0;
  }
  for (i = 0; i <= m; ++i)
    for (k = 0; k < 26; ++k) {
      long long& d = mat.a[q[i]][trie[q[i]].ch[k]];
      d = max(d, (long long)val[trie[q[i]].ch[k]]);
    }
}
matrix operator*(const matrix& a, const matrix& b) {
  int i, j, k;
  matrix c;
  for (i = 0; i <= n; ++i)
    for (j = 0; j <= n; ++j) {
      c.a[i][j] = -(1LL << 60);
      for (k = 0; k <= n; ++k)
        c.a[i][j] = max(c.a[i][j], a.a[i][k] + b.a[k][j]);
    }
  return c;
}
matrix qp(const matrix& b, long long e) {
  matrix t, ans;
  t = b, ans = unit;
  while (e) {
    if (e & 1) ans = ans * t;
    t = t * t;
    e >>= 1;
  }
  return ans;
}
long long work() {
  long long ans = 0;
  int i;
  n = m;
  mat = qp(mat, l);
  for (i = 0; i <= n; ++i) ans = max(ans, mat.a[0][i]);
  return ans;
}
int main() {
  int i;
  cin >> n >> l;
  for (i = 1; i <= n; ++i) cin >> a[i];
  for (i = 1; i <= n; ++i) {
    cin >> st[i] + 1;
    val[ins(st[i] + 1)] += a[i];
  }
  getnext();
  buildmatrix();
  cout << work() << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}
