Problem: Barney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible.

<image>

Initially, happiness level of Nora is 0. Nora loves some pickup lines like "I'm falling for you" and stuff. Totally, she knows n pickup lines, each consisting only of lowercase English letters, also some of them may be equal (in writing, but different in pronouncing or meaning though). Every time Nora sees i-th pickup line as a consecutive subsequence of Barney's text message her happiness level increases by ai. These substrings may overlap, for example, Nora will see the pickup line aa twice and the pickup line ab once in text message aaab.

Due to texting app limits, Barney's text may have up to l characters.

Barney asked you to help him make Nora as much happy as possible, it's gonna be legen...

Input

The first line of input contains two integers n and l (1 ≤ n ≤ 200, 1 ≤ l ≤ 1014) — the number of pickup lines and the maximum length of Barney's text.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100), meaning that Nora's happiness level increases by ai after every time seeing i-th pickup line.

The next n lines contain the pickup lines. i-th of them contains a single string si consisting of only English lowercase letter. Summary length of all pickup lines does not exceed 200.

All strings are not empty.

Output

Print the only integer — the maximum possible value of Nora's happiness level after reading Barney's text.

Examples

Input

3 6
3 2 1
heart
earth
art


Output

6


Input

3 6
3 2 8
heart
earth
art


Output

16

Note

An optimal answer for the first sample case is hearth containing each pickup line exactly once.

An optimal answer for the second sample case is artart.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline string tostr(const T &x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
inline long long parse(const string &s) {
  stringstream ss(s);
  long long x;
  ss >> x;
  return x;
}
const double EPS = 1e-12;
const int INF = 1000 * 1000 * 1000;
const long long LINF = INF * 1ll * INF;
const double DINF = 1e200;
const double PI = 3.1415926535897932384626433832795l;
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long gcdex(long long a, long long b, long long &x, long long &y) {
  if (!a) {
    x = 0, y = 1;
    return b;
  }
  long long k = b / a;
  long long g = gcdex(b - k * a, a, y, x);
  x -= k * y;
  return g;
}
long long inv(long long a, long long m) {
  long long x, y, g;
  g = gcdex(a, m, x, y);
  return (x % (m / g) + m / g) % m / g;
}
long long crt(long long a1, long long m1, long long a2, long long m2) {
  long long a = (a2 - a1 % m2 + m2) % m2;
  long long x, y, g;
  g = gcdex(m1, m2, x, y);
  if (a % g) return -1;
  long long m = m1 / g * m2;
  x *= a / g;
  x = (x % m2 + m2) % m2;
  long long r = (a1 + x * m1) % m;
  assert(r % m1 == a1 && r % m2 == a2);
  return r;
}
long long powmod(long long a, long long p, long long m) {
  long long r = 1;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
bool isprime(long long a) {
  if (a <= 1) return false;
  for (long long i = 2; i * i <= a; ++i) {
    if (a % i == 0) return false;
  }
  return true;
}
long long sqrtup(long long a) {
  if (!a) return 0;
  long long x = max(0ll, (long long)sqrt((double)a));
  while (x * x >= a) --x;
  while ((x + 1) * (x + 1) < a) ++x;
  return x + 1;
}
long long isqrt(long long a) {
  long long x = max(0ll, (long long)sqrt((double)a));
  while (x * x > a) --x;
  while ((x + 1) * (x + 1) <= a) ++x;
  return x;
}
long long sgn(long long x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
template <class T>
ostream &operator<<(ostream &s, const vector<T> &v);
template <class A, class B>
ostream &operator<<(ostream &s, const pair<A, B> &p);
template <class K, class V>
ostream &operator<<(ostream &s, const map<K, V> &m);
template <class T, size_t N>
ostream &operator<<(ostream &s, const array<T, N> &a);
template <class T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  s << '[';
  for (int i = 0; i < (((int)(v).size())); ++i) {
    if (i) s << ',';
    s << v[i];
  }
  s << ']';
  return s;
}
template <class A, class B>
ostream &operator<<(ostream &s, const pair<A, B> &p) {
  s << "(" << p.first << "," << p.second << ")";
  return s;
}
template <class K, class V>
ostream &operator<<(ostream &s, const map<K, V> &m) {
  s << "{";
  bool f = false;
  for (const auto &it : m) {
    if (f) s << ",";
    f = true;
    s << it.first << ": " << it.second;
  }
  s << "}";
  return s;
}
template <class T>
ostream &operator<<(ostream &s, const set<T> &m) {
  s << "{";
  bool f = false;
  for (const auto &it : m) {
    if (f) s << ",";
    f = true;
    s << it;
  }
  s << "}";
  return s;
}
template <class T>
ostream &operator<<(ostream &s, const multiset<T> &m) {
  s << "{";
  bool f = false;
  for (const auto &it : m) {
    if (f) s << ",";
    f = true;
    s << it;
  }
  s << "}";
  return s;
}
template <class T, size_t N>
ostream &operator<<(ostream &s, const array<T, N> &a) {
  s << '[';
  for (int i = 0; i < (((int)(a).size())); ++i) {
    if (i) s << ',';
    s << a[i];
  }
  s << ']';
  return s;
}
template <size_t n, class... T>
struct put1 {
  static ostream &put(ostream &s, const tuple<T...> &t) {
    s << get<sizeof...(T) - n>(t);
    if (n > 1) s << ',';
    return put1<n - 1, T...>::put(s, t);
  }
};
template <class... T>
struct put1<0, T...> {
  static ostream &put(ostream &s, const tuple<T...> &t) { return s; }
};
template <class... T>
ostream &operator<<(ostream &s, const tuple<T...> &t) {
  s << "(";
  put1<sizeof...(T), T...>::put(s, t);
  s << ")";
  return s;
}
ostream &put2(ostream &s, const tuple<> &t) { return s; }
template <class U>
ostream &put2(ostream &s, const tuple<U> &t) {
  return s << get<0>(t);
}
template <class U, class V, class... T>
ostream &put2(ostream &s, const tuple<U, V, T...> &t) {
  return s << t;
}
vector<string> P;
map<string, int> I;
vector<long long> C;
struct mat {
  vector<vector<long long>> a;
  mat(int n) : a(n, vector<long long>(n, -LINF)) {
    for (int i = 0; i < (n); ++i) a[i][i] = 0;
  }
  mat operator*(const mat &b) const {
    mat r(((int)(a).size()));
    for (int i = 0; i < (((int)(a).size())); ++i) {
      for (int j = 0; j < (((int)(a).size())); ++j) {
        r.a[i][j] = -LINF;
        for (int k = 0; k < (((int)(a).size())); ++k) {
          long long t1 = a[i][k];
          long long t2 = b.a[k][j];
          if (t1 < 0 || t2 < 0) continue;
          r.a[i][j] = max(r.a[i][j], t1 + t2);
        }
      }
    }
    return r;
  }
};
mat pw(mat a, long long p) {
  mat r(((int)(a.a).size()));
  while (p) {
    if (p & 1) r = r * a;
    p >>= 1;
    a = a * a;
  }
  return r;
}
void gen() {
  int n = 1, k = 200;
  long long l = LINF / 10000;
  cout << n << ' ' << l << endl;
  for (int i = 0; i < (n); ++i) cout << rand() % 100 + 1 << ' ';
  cout << endl;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (k); ++j) cout << (char)('a' + rand() % 26);
    cout << endl;
  }
}
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  if (argc > 1) {
    gen();
    return 0;
  }
  int n;
  long long l;
  cin >> n >> l;
  vector<long long> A(n);
  for (int i = 0; i < (n); ++i) cin >> A[i];
  map<string, long long> M;
  for (int i = 0; i < (n); ++i) {
    string s;
    cin >> s;
    M[s] += A[i];
    for (int k = 0; k < (((int)(s).size()) + 1); ++k) {
      string p = s.substr(0, k);
      if (I.count(p)) continue;
      I[p] = ((int)(P).size());
      P.push_back(p);
    }
  }
  C.resize(((int)(P).size()));
  for (int i = 0; i < (((int)(P).size())); ++i) {
    string p = P[i];
    for (int k = 0; k < (((int)(p).size()) + 1); ++k) {
      string s = p.substr(k);
      auto it = M.find(s);
      if (it != M.end()) C[i] += it->second;
    }
  }
  mat m(((int)(P).size()));
  for (int i = 0; i < (((int)(P).size())); ++i) {
    m.a[i][i] = -LINF;
    for (char c = 'a'; c <= 'z'; ++c) {
      string s = P[i] + c;
      bool f = false;
      for (int k = 0; k < (((int)(s).size()) + 1); ++k) {
        string t = s.substr(k);
        auto it = I.find(t);
        if (it == I.end()) continue;
        int j = it->second;
        m.a[i][j] = max(m.a[i][j], C[j]);
        f = true;
        break;
      }
      assert(f);
    }
  }
  m = pw(m, l);
  long long r = -LINF;
  for (int i = 0; i < (((int)(P).size())); ++i) {
    r = max(r, m.a[I[""]][i]);
  }
  assert(r >= 0);
  cout << r;
  return 0;
}