#include <bits/stdc++.h>
using namespace std;
const int N = 301;
int i, j, l, r, k, x, y, z, t, tot;
int f[N][26], sum[N], p[N], q[N];
long long A[N][N], E[N][N], tmp[N][N];
long long n, m, a[N], INF, ans;
char s[N];
void build(int value) {
  int x = 0, t;
  for (int i = 0; i < strlen(s); i++) {
    t = s[i] - 'a';
    if (!f[x][t]) f[x][t] = ++tot;
    x = f[x][t];
  }
  sum[x] += value;
}
void init() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    cin >> s;
    build(a[i]);
  }
}
void Ac() {
  int l = 0, r = 0;
  for (i = 0; i < 26; i++)
    if (f[0][i]) q[++r] = f[0][i];
  while (l != r) {
    l++;
    x = q[l];
    for (i = 0; i < 26; i++)
      if (f[x][i]) {
        q[++r] = f[x][i];
        y = p[x];
        while (!f[y][i] && y) y = p[y];
        if (f[y][i]) y = f[y][i];
        p[f[x][i]] = y;
        sum[f[x][i]] += sum[y];
      }
  }
}
void cal(long long c[][N], long long a[][N], long long b[][N]) {
  int i, j, k;
  for (i = 0; i <= tot; i++)
    for (j = 0; j <= tot; j++) tmp[i][j] = INF;
  for (i = 0; i <= tot; i++)
    for (j = 0; j <= tot; j++)
      for (k = 0; k <= tot; k++)
        if (a[i][k] + b[k][j] > tmp[i][j]) tmp[i][j] = a[i][k] + b[k][j];
  for (i = 0; i <= tot; i++)
    for (j = 0; j <= tot; j++) c[i][j] = tmp[i][j];
}
void pr(long long a[][N]) {
  for (i = 0; i <= tot; i++) {
    for (j = 0; j <= tot; j++)
      if (a[i][j] > INF / 2)
        cout << a[i][j] << ' ';
      else
        cout << "* ";
    printf("\n");
  }
  printf("\n");
}
void Matrix() {
  INF = 1LL << 60;
  INF *= -1;
  for (i = 0; i <= tot; i++)
    for (j = 0; j <= tot; j++) A[i][j] = E[i][j] = INF;
  for (i = 0; i <= tot; i++) E[i][i] = 0;
  for (i = 0; i <= tot; i++)
    for (j = 0; j < 26; j++) {
      y = i;
      while (y && !f[y][j]) y = p[y];
      if (f[y][j]) y = f[y][j];
      A[i][y] = sum[y];
    }
  while (m) {
    if (m % 2) cal(E, E, A);
    cal(A, A, A);
    m /= 2;
  }
  ans = E[0][0];
  for (i = 1; i <= tot; i++) ans = max(ans, E[0][i]);
  cout << ans;
}
int main() {
  init();
  Ac();
  Matrix();
}
