#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 400;
const long long mod = 1e9 + 7;
const long long inf = 1e17 + 500;
string s[maxn];
long long a[maxn];
string t;
long long n;
long long ger[maxn][maxn];
long long tvi[maxn][maxn];
long long sav[maxn][maxn];
long long tyu[maxn][maxn];
long long star[maxn];
long long m;
long long f(string h) {
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (h.size() >= s[i].size()) {
      bool good = 1;
      for (long long j = 0; j < s[i].size(); j++) {
        if (h[j] != s[i][j]) {
          good = 0;
        }
      }
      if (good) {
        ans += a[i];
      }
    }
  }
  return ans;
}
void tavtosav() {
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      sav[i][j] = tvi[i][j];
    }
  }
}
void jelosav() {
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      long long v = -inf;
      for (long long z = 0; z < m; z++) {
        v = max(v, sav[i][z] + ger[z][j]);
      }
      tyu[i][j] = v;
    }
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      sav[i][j] = tyu[i][j];
    }
  }
}
void tavbasavtotav() {
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      long long v = -inf;
      for (long long z = 0; z < m; z++) {
        v = max(v, sav[i][z] + tvi[z][j]);
      }
      tyu[i][j] = v;
    }
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < m; j++) {
      tvi[i][j] = tyu[i][j];
    }
  }
}
void tav(long long l) {
  if (l == 0) {
    for (long long i = 0; i < m; i++) {
      for (long long j = 0; j < m; j++) {
        tvi[i][j] = -inf;
      }
      tvi[i][i] = 0;
    }
    return;
  }
  tav(l / 2);
  tavtosav();
  if (l & 1) {
    jelosav();
  }
  tavbasavtotav();
}
bool sub(string a, string b) {
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) {
      return 0;
    }
  }
  return 1;
}
map<string, int> ml;
int main() {
  long long l;
  cin >> n >> l;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    ml[s[i]] += a[i];
  }
  long long np = 0;
  for (long long i = 0; i < n; i++) {
    long long v = ml[s[i]];
    if (v != 0) {
      a[np] = v;
      s[np] = s[i];
      np++;
      ml[s[i]] = 0;
    }
  }
  n = np;
  for (long long i = 0; i < n; i++) {
    star[i] = t.size();
    t += s[i];
    t += "#";
  }
  m = t.size();
  for (long long i = 0; i < maxn; i++) {
    for (long long j = 0; j < maxn; j++) {
      ger[i][j] = -inf;
    }
  }
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == '#') {
      ger[i][i] = 0;
    } else {
      string h;
      for (int j = i + 1; t[j] != '#'; j++) {
        h += t[j];
      }
      ger[i][i + 1] = f(t[i] + h);
      for (int j = 0; j < n; j++) {
        if (h.size() < s[j].size() && sub(h, s[j])) {
          ger[i][star[j]] = f(t[i] + s[j]);
        }
      }
    }
  }
  tav(l);
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    if (t[i] == '#') {
      for (int j = 0; j < m; j++) {
        ans = max(ans, tvi[j][i]);
      }
    }
  }
  cout << ans;
}
