#include <bits/stdc++.h>
using namespace std;
char str[205];
int A[205];
string S[205];
vector<string> nd;
long long int cost[205][205];
long long int dist[205][205];
long long int cur[205][205];
int n, sz;
void merge(long long int A[205][205], long long int B[205][205]) {
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < sz; j++) {
      cur[i][j] = -1;
      for (int k = 0; k < sz; k++) {
        if (A[i][k] == -1 || B[k][j] == -1) continue;
        cur[i][j] = max(cur[i][j], A[i][k] + B[k][j]);
      }
    }
  }
}
void solve(long long int K) {
  if (K == 0) {
    memset(dist, -1, sizeof(dist));
    for (int i = 0; i < sz; i++) dist[i][i] = 0;
    return;
  }
  solve(K / 2);
  merge(dist, dist);
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < sz; j++) dist[i][j] = cur[i][j];
  if (K % 2 == 1) {
    merge(dist, cost);
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) dist[i][j] = cur[i][j];
  }
}
int main() {
  long long int L;
  scanf("%d %lld", &n, &L);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  nd.push_back("");
  for (int i = 0; i < n; i++) {
    scanf("%s", &str);
    S[i] = str;
    string now = "";
    for (int j = 0; j < S[i].size(); j++) {
      now += S[i][j];
      nd.push_back(now);
    }
  }
  sort(nd.begin(), nd.end());
  nd.erase(unique(nd.begin(), nd.end()), nd.end());
  sz = nd.size();
  memset(cost, -1, sizeof(cost));
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < 26; j++) {
      string s = nd[i];
      char c = 'a' + j;
      s += c;
      long long int sum = 0;
      for (int k = 0; k < n; k++) {
        if (S[k].size() <= s.size() &&
            S[k] == s.substr(s.size() - S[k].size(), S[k].size()))
          sum += A[k];
      }
      int pos = -1;
      for (int k = 0; k < sz; k++) {
        if (nd[k].size() <= s.size() &&
            nd[k] == s.substr(s.size() - nd[k].size(), nd[k].size())) {
          if (pos == -1 || nd[pos].size() < nd[k].size()) pos = k;
        }
      }
      cost[i][pos] = max(cost[i][pos], sum);
    }
  }
  solve(L);
  long long int ret = 0;
  for (int i = 0; i < sz; i++) ret = max(ret, dist[0][i]);
  printf("%lld\n", ret);
  return 0;
}
