#include <bits/stdc++.h>
using namespace std;
const long long N = 205;
long long n, m, tot, val[N], h[N], ch[N][26], fail[N], v, i, ans, cur, u, j, c,
    len;
char a[N];
struct w {
  long long c[N][N];
  w() {
    for (long long i = 0; i < N; i++)
      for (long long j = 0; j < N; j++) c[i][j] = -1e18;
  }
  w operator*(w x) {
    w res;
    for (long long k = 0; k <= tot; k++)
      for (long long i = 0; i <= tot; i++)
        for (long long j = 0; j <= tot; j++)
          res.c[i][j] = max(res.c[i][j], c[i][k] + x.c[k][j]);
    return res;
  }
} k;
w pow(w x, long long y) {
  w res;
  for (long long i = 0; i <= tot; ++i) res.c[i][i] = 0;
  while (y) {
    if (y & 1) res = res * x;
    x = x * x;
    y >>= 1;
  }
  return res;
}
int main() {
  scanf("%d%lld", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%d", &val[i]);
  for (i = 1; i <= n; ++i) {
    scanf("%s", a + 1);
    cur = 0;
    len = strlen(a + 1);
    for (long long j = 1; j <= len; j++) {
      c = a[j] - 'a';
      if (!ch[cur][c]) ch[cur][c] = ++tot;
      cur = ch[cur][c];
    }
    h[cur] += val[i];
  }
  deque<long long> q;
  for (i = 0; i < 26; ++i) {
    v = ch[0][i];
    if (v) q.push_back(v);
  }
  while (!q.empty()) {
    u = q.front();
    q.pop_front();
    h[u] += h[fail[u]];
    for (i = 0; i < 26; ++i) {
      v = ch[u][i];
      if (v)
        fail[v] = ch[fail[u]][i], q.push_back(v);
      else
        ch[u][i] = ch[fail[u]][i];
    }
  }
  for (i = 0; i <= tot; ++i)
    for (j = 0; j < 26; ++j) cur = ch[i][j], k.c[i][cur] = h[cur];
  k = pow(k, m);
  for (long long i = 0; i <= tot; ++i) ans = max(ans, k.c[0][i]);
  printf("%lld", ans);
}
