#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
struct NODE {
  char x;
  int ind;
  int idx;
  int ridx;
  long long val;
  NODE *parent;
  NODE *suf;
  NODE *dsuf;
  NODE *next[27];
  NODE *dat[27];
  NODE() {
    x = ind = 0, idx = -1, parent = suf = dsuf = 0, ridx = val = 0;
    for (int i = 0; i < 27; i++) next[i] = 0, dat[i] = 0;
  }
} root;
int n;
int ri;
long long m;
int a[300];
string s[300];
long long val[300];
NODE *rr[300];
struct MAT {
  long long x[205][205];
  MAT() {
    for (int i = 0; i < ri; i++)
      for (int j = 0; j < ri; j++) x[i][j] = -1;
  }
  MAT operator*(const MAT &p) const {
    int i, j, k;
    MAT res;
    for (i = 0; i < ri; i++)
      for (k = 0; k < ri; k++)
        for (j = 0; j < ri; j++) {
          if (x[i][k] == -1 || p.x[k][j] == -1) continue;
          res.x[i][j] = max(res.x[i][j], x[i][k] + p.x[k][j]);
        }
    return res;
  }
};
MAT x;
MAT ans;
int main() {
  int i, j, k, l;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) cin >> s[i];
  ri = 1;
  rr[0] = &root;
  for (i = 0; i < n; i++) {
    NODE *now = &root;
    for (auto e : s[i]) {
      if (now->next[e - 'a'] == 0)
        now->next[e - 'a'] = new NODE(), now->next[e - 'a']->x = e,
                      now->next[e - 'a']->parent = now,
                      rr[ri] = now->next[e - 'a'],
                      now->next[e - 'a']->ridx = ri++;
      now = now->next[e - 'a'];
    }
    now->ind = 1;
    now->idx = i;
    now->val += a[i];
  }
  vector<NODE *> v;
  v.push_back(&root);
  for (k = 0; k < v.size(); k++) {
    auto e = v[k];
    if (e == &root)
      e->suf = NULL, e->dsuf = NULL;
    else {
      NODE *now = e->parent;
      while (!e->suf) {
        if (now == &root)
          e->suf = &root;
        else if (now->suf->next[e->x - 'a'])
          e->suf = now->suf->next[e->x - 'a'];
        else
          now = now->suf;
      }
      if (e->suf->ind)
        e->dsuf = e->suf;
      else
        e->dsuf = e->suf->dsuf;
    }
    for (i = 0; i < 27; i++)
      if (e->next[i]) v.push_back(e->next[i]);
  }
  for (i = 0; i < v.size(); i++) {
    auto e = v[i];
    if (i == 0) {
      for (j = 0; j < 27; j++) {
        if (e->next[j])
          e->dat[j] = e->next[j];
        else
          e->dat[j] = &root;
      }
    } else {
      for (j = 0; j < 27; j++) {
        NODE *now = v[i];
        if (now->next[j])
          e->dat[j] = now->next[j];
        else
          e->dat[j] = now->suf->dat[j];
        if (!now) e->dat[j] = &root;
      }
    }
  }
  for (i = 0; i < ri; i++) {
    long long sum = 0;
    NODE *now = rr[i];
    while (now != NULL) {
      sum += now->val;
      now = now->dsuf;
    }
    val[i] = sum;
  }
  for (i = 0; i < ri; i++)
    for (j = 0; j < ri; j++) x.x[i][j] = ans.x[i][j] = -1;
  for (i = 0; i < ri; i++) {
    for (j = 0; j < 26; j++) {
      x.x[i][rr[i]->dat[j]->ridx] = val[rr[i]->dat[j]->ridx];
    }
  }
  ans.x[0][0] = 0;
  while (m) {
    if (m % 2) ans = ans * x;
    x = x * x;
    m /= 2;
  }
  long long ma = 0;
  for (i = 0; i < ri; i++)
    for (j = 0; j < ri; j++) ma = max(ma, ans.x[i][j]);
  cout << ma;
  return 0;
}
