#include <bits/stdc++.h>
using namespace std;
const int A = 256;
int sz = 0;
using CHAR = uint8_t;
struct Node {
  int index;
  Node* s;
  Node* go[A];
  Node* p;
  int happy;
  CHAR c;
  Node() {}
  Node(CHAR c, Node* p) : s(NULL), p(p), happy(0), c(c) {
    for (int i = 0; i < A; ++i) go[i] = NULL;
    index = sz++;
  }
};
typedef Node* pNode;
Node nodes[1000];
pNode root = new (&nodes[0]) Node(' ', NULL);
void add_string(const string& s, int w) {
  pNode current = root;
  for (int i = 0; i < (int)s.size(); ++i) {
    CHAR c = s[i];
    if (current->go[c] == NULL) {
      current->go[c] = new (&nodes[sz]) Node(c, current);
    }
    current = current->go[c];
  }
  current->happy += w;
}
int n, m, p;
string dic, s;
inline pNode go(pNode u, CHAR c);
inline pNode get_link(pNode u) {
  if (u->s != NULL) {
    return u->s;
  }
  u->s = (u == root || u->p == root) ? root : go(get_link(u->p), u->c);
  get_link(u->s);
  u->happy += u->s->happy;
  return u->s;
}
inline pNode go(pNode u, CHAR c) {
  if (u->go[c] != NULL) {
    return u->go[c];
  }
  return u->go[c] = (u == root) ? root : go(get_link(u), c);
}
const int64_t UNDEF = numeric_limits<int64_t>::min();
vector<vector<int64_t>> apply(const vector<vector<int64_t>>& a,
                              const vector<vector<int64_t>>& b) {
  vector<vector<int64_t>> dp(sz, vector<int64_t>(sz, UNDEF));
  for (int from = 0; from < sz; ++from) {
    for (int middle = 0; middle < sz; ++middle) {
      if (a[from][middle] == UNDEF) {
        continue;
      }
      for (int to = 0; to < sz; ++to) {
        if (b[middle][to] != UNDEF) {
          dp[from][to] = max(dp[from][to], a[from][middle] + b[middle][to]);
        }
      }
    }
  }
  return dp;
}
void print_state(int x) {
  cout << x << ':' << nodes[x].happy << ':';
  while (x) {
    cout << nodes[x].c;
    x = nodes[x].p->index;
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  long long l;
  cin >> n >> l;
  vector<int> w(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    add_string(s, w[i]);
  }
  for (int i = 0; i < sz; ++i) {
    get_link(&nodes[i]);
  }
  vector<vector<int64_t>> dp(sz, vector<int64_t>(sz, UNDEF));
  for (int i = 0; i < sz; ++i) {
    for (char c = 'a'; c <= 'z'; ++c) {
      pNode from = &nodes[i];
      pNode to = go(from, c);
      dp[from->index][to->index] = to->happy;
    }
  }
  vector<vector<int64_t>> current(sz, vector<int64_t>(sz, UNDEF));
  bool first = true;
  long long k = 1;
  while (l) {
    if (l & k) {
      if (first) {
        current = dp;
        first = false;
      } else {
        current = apply(current, dp);
      }
      l ^= k;
    }
    dp = apply(dp, dp);
    k <<= 1;
  }
  int64_t ans = 0;
  for (int i = 0; i < sz; ++i) {
    ans = max(ans, current[0][i]);
  }
  std::cout << ans << std::endl;
  return 0;
}
