#include <bits/stdc++.h>
using namespace std;
template <class T>
bool remin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool remax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int nxt() {
  int first;
  scanf("%d", &first);
  return first;
}
long long gcd(long long a, long long b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
struct pt {
  long double first, second;
  pt() {}
  pt(long double first, long double second) : first(first), second(second) {}
  inline pt operator-(const pt &r) const {
    return pt(first - r.first, second - r.second);
  }
  inline pt operator+(const pt &r) const {
    return pt(first + r.first, second + r.second);
  }
  inline pt operator*(const long double &r) const {
    return pt(first * r, second * r);
  }
  inline long double sqlen() const {
    return abs(first * first + second * second);
  }
  pt rot(long double co, long double si) const {
    return pt(first * co - si * second, si * first + co * second);
  }
  pt rot(long double ang) const { return rot(cosl(ang), sinl(ang)); }
  long double len() const { return sqrtl(sqlen()); }
  inline bool operator<(const pt &r) const {
    if (first != r.first) return first < r.first;
    return second < r.second;
  }
  inline bool operator==(const pt &r) const {
    return first == r.first && second == r.second;
  }
};
ostream &operator<<(ostream &os, const pt &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
inline long double cross(const pt &l, const pt &r) {
  return l.first * r.second - l.second * r.first;
}
inline long double dot(const pt &l, const pt &r) {
  return l.first * r.first + l.second * r.second;
}
long long pwmod(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
template <typename T>
inline T sqr(T first) {
  return first * first;
}
bool remin(long long &first, long long second) {
  if (first > second) {
    first = second;
    return 1;
  }
  return 0;
}
const int K = 26;
struct vertex {
  int next[K];
  vector<int> who;
  int p;
  char pch;
  int link;
  int go[K];
};
vertex t[400];
int sz;
void init() {
  t[0].p = t[0].link = -1;
  memset(t[0].next, 255, sizeof t[0].next);
  memset(t[0].go, 255, sizeof t[0].go);
  sz = 1;
}
void add_string(const string &s, int id) {
  int v = 0;
  for (size_t i = 0; i < s.length(); ++i) {
    char c = s[i] - 'a';
    if (t[v].next[c] == -1) {
      memset(t[sz].next, 255, sizeof t[sz].next);
      memset(t[sz].go, 255, sizeof t[sz].go);
      t[sz].link = -1;
      t[sz].p = v;
      t[sz].pch = c;
      t[v].next[c] = sz++;
    }
    v = t[v].next[c];
  }
  t[v].who.push_back(id);
}
int go(int v, char c);
int get_link(int v) {
  if (t[v].link == -1)
    if (v == 0 || t[v].p == 0)
      t[v].link = 0;
    else
      t[v].link = go(get_link(t[v].p), t[v].pch);
  return t[v].link;
}
int go(int v, char c) {
  if (t[v].go[c] == -1)
    if (t[v].next[c] != -1)
      t[v].go[c] = t[v].next[c];
    else
      t[v].go[c] = v == 0 ? 0 : go(get_link(v), c);
  return t[v].go[c];
}
long long cost[400][400];
const long long inf = LLONG_MAX / 2;
vector<vector<long long> > getAns(long long n) {
  if (n == 1) {
    vector<vector<long long> > ret(sz, vector<long long>(sz, 0));
    for (int i = 0; i < (int)(sz); i++) {
      for (int j = 0; j < (int)(sz); j++) {
        ret[i][j] = cost[i][j];
      }
    }
    return ret;
  }
  vector<vector<long long> > cur(sz, vector<long long>(sz, -inf));
  vector<vector<long long> > ch = getAns(n / 2);
  for (int k = 0; k < (int)(sz); k++) {
    for (int i = 0; i < (int)(sz); i++) {
      for (int j = 0; j < (int)(sz); j++) {
        remax(cur[i][j], ch[i][k] + ch[k][j]);
      }
    }
  }
  for (int i = 0; i < (int)(sz); i++) {
    for (int j = 0; j < (int)(sz); j++) {
    }
  }
  vector<vector<long long> > ret;
  if (n & 1) {
    ret.assign(sz, vector<long long>(sz, -inf));
    for (int k = 0; k < (int)(sz); k++) {
      for (int i = 0; i < (int)(sz); i++) {
        for (int j = 0; j < (int)(sz); j++) {
          remax(ret[i][j], cur[i][k] + cost[k][j]);
        }
      }
    }
  } else {
    ret.swap(cur);
  }
  return ret;
}
void solve() {
  int n;
  long long l;
  cin >> n >> l;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  vector<string> s(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> s[i];
  }
  init();
  for (int i = 0; i < (int)(n); i++) {
    add_string(s[i], i);
  }
  long long add_cost[sz];
  memset(add_cost, 0, sizeof(add_cost));
  for (int i = 0; i < (int)(sz); i++) {
    int v = i;
    while (v != 0) {
      for (int id : t[v].who) {
        add_cost[i] += a[id];
      }
      v = get_link(v);
    }
  }
  for (int i = 0; i < (int)(sz); i++) {
    for (int j = 0; j < (int)(sz); j++) {
      cost[i][j] = -inf;
    }
  }
  for (int i = 0; i < (int)(sz); i++) {
    for (int j = 0; j < (int)(26); j++) {
      int v = go(i, j);
      remax(cost[i][v], add_cost[v]);
    }
  }
  auto ans = getAns(l);
  long long ret = 0;
  for (int i = 0; i < (int)(sz); i++) {
    remax(ret, ans[0][i]);
  }
  cout << ret << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
