#include <bits/stdc++.h>
using namespace std;
const int MAXN = 220;
int son[MAXN][30], f[MAXN], w[MAXN];
long long val[MAXN];
char s[MAXN];
int size, n;
long long m;
struct Mat {
  long long map[MAXN][MAXN];
  int l, r;
  Mat operator+(const Mat &b) const {
    Mat c;
    memset(c.map, -1, sizeof(c.map));
    c.l = l;
    c.r = b.r;
    for (int i = 0; i <= l; i++)
      for (int j = 0; j <= b.r; j++)
        for (int p = 0; p <= r; p++)
          if (~map[i][p] && ~b.map[p][j])
            c.map[i][j] = max(c.map[i][j], map[i][p] + b.map[p][j]);
    return c;
  }
} P, M, O;
int NewNode(int u, int t) {
  int id = ++size;
  memset(son[id], 0, sizeof(son[id]));
  val[id] = 0;
  son[u][t] = id;
  return id;
}
void Insert(char *s, int w) {
  int len = strlen(s), cur = 0;
  for (int i = 0; i < len; i++) {
    int t = s[i] - 'a' + 1;
    int nxt = son[cur][t];
    if (!nxt) nxt = NewNode(cur, t);
    cur = nxt;
  }
  val[cur] += w;
}
void Build() {
  queue<int> q;
  for (int i = 1; i <= 26; i++) {
    int t = son[0][i];
    if (t) {
      f[t] = 0;
      q.push(t);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 1; i <= 26; i++) {
      int t = son[u][i];
      if (!t) {
        son[u][i] = son[f[u]][i];
        continue;
      }
      int j = f[u];
      q.push(t);
      while (j && !son[j][i]) j = f[j];
      f[t] = son[j][i];
      val[t] += val[f[t]];
    }
  }
}
void Pow(long long k) {
  memset(P.map, -1, sizeof(P.map));
  P.l = P.r = size;
  for (int i = 0; i <= size; i++) P.map[i][i] = 0;
  while (k) {
    if (k & 1) P = P + M;
    M = M + M;
    k >>= 1;
  }
}
void MakM() {
  M.l = M.r = size;
  memset(M.map, -1, sizeof(M.map));
  for (int i = 0; i <= size; i++) {
    for (int j = 1; j <= 26; j++) {
      int t = son[i][j];
      if (t) M.map[t][i] = val[t];
    }
  }
  Pow(m);
  memset(O.map, -1, sizeof(O.map));
  O.l = size;
  O.r = 0;
  O.map[0][0] = 0;
  O = P + O;
  long long ans = 0;
  for (int i = 0; i <= size; i++) ans = max(ans, O.map[i][0]);
  printf("%lld", ans);
}
int main() {
  scanf("%d%lld", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    Insert(s, w[i]);
  }
  Build();
  MakM();
  return 0;
}
