#include <bits/stdc++.h>
using namespace std;
long long n;
long long l, val[205], cst[205];
char s[205];
long long ch[205][26], fail[205], cnt = 1;
void Insert(char *s, long long w) {
  long long len = strlen(s), r = 0;
  for (long long i = 0; i < len; i++) {
    long long val = s[i] - 'a';
    if (!ch[r][val]) ch[r][val] = cnt++;
    r = ch[r][val];
  }
  val[r] += w;
}
long long Q[205], L, R;
void build(long long r) {
  Q[L = 0] = r, R = 1;
  long long p, c;
  for (; L < R;) {
    r = Q[L++];
    for (long long i = 0; i < 26; i++)
      if (c = ch[r][i]) {
        Q[R++] = c;
        for (p = fail[r]; p != 0 && ch[p][i] == 0; p = fail[p])
          ;
        long long tmp = ch[p][i];
        if (tmp && tmp != c)
          fail[c] = tmp;
        else
          fail[c] = 0;
        val[c] += val[fail[c]];
      } else {
        for (p = fail[r]; p != 0 && ch[p][i] == 0; p = fail[p])
          ;
        long long tmp = ch[p][i];
        if (tmp)
          ch[r][i] = tmp;
        else
          ch[r][i] = 0;
      }
  }
}
long long dp[205][205], dp2[205][205], dp3[205][205], A[205][205], B[205][205];
void solve(long long a[205][205], long long b[205][205],
           long long c[205][205]) {
  memcpy(A, a, sizeof A), memcpy(B, b, sizeof B);
  for (long long k = 0; k < cnt; k++)
    for (long long i = 0; i < cnt; i++)
      for (long long j = 0; j < cnt; j++)
        if (A[i][k] != -0x3f3f3f3f3f3f3f3fll &&
            B[k][j] != -0x3f3f3f3f3f3f3f3fll)
          c[i][j] = max(c[i][j], A[i][k] + B[k][j]);
}
int main() {
  scanf("%lld%lld", &n, &l);
  for (long long i = 1; i <= n; i++) scanf("%lld", &cst[i]);
  fail[0] = -1;
  for (long long i = 1; i <= n; i++) {
    scanf("%s", s);
    Insert(s, cst[i]);
  }
  build(0);
  for (long long i = 0; i < cnt; i++)
    for (long long j = 0; j < cnt; j++)
      dp[i][j] = dp2[i][j] = -0x3f3f3f3f3f3f3f3fll;
  for (long long i = 0; i < cnt; i++) dp[i][i] = dp2[i][i] = 0;
  for (long long i = 0; i < cnt; i++)
    for (long long j = 0; j < 26; j++) dp[i][ch[i][j]] = val[ch[i][j]];
  for (; l; l >>= 1, solve(dp, dp, dp))
    if (l & 1) solve(dp, dp2, dp2);
  printf("%lld\n", *max_element(dp2[0], dp2[0] + cnt + 1));
}
