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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Aho {
  enum { ALPHA = 30 };
  struct Node {
    long long p = -1, link = -1, id = -1, superLink = -1;
    long long v = 0;
    long long next[ALPHA], go[ALPHA];
    bool leaf = false;
    char ch;
    Node(long long p = -1, char c = '$') : p(p), ch(c) {
      fill(begin(next), end(next), -1);
      fill(begin(go), end(go), -1);
    }
  };
  vector<Node> nodes;
  void insert(string &s, long long id) {
    long long v = 0;
    for (char ch : s) {
      long long c = ch - 'a';
      if (nodes[v].next[c] == -1) {
        Node aux = Node(v, ch);
        nodes[v].next[c] = (long long)nodes.size();
        nodes.push_back(aux);
      }
      v = nodes[v].next[c];
    }
    nodes[v].leaf = true;
    nodes[v].v += id;
  }
  long long go(long long v, char ch) {
    if (v >= (long long)nodes.size()) return 0;
    long long c = ch - 'a';
    if (nodes[v].go[c] == -1) {
      if (nodes[v].next[c] != -1) {
        nodes[v].go[c] = nodes[v].next[c];
      } else {
        if (v == 0)
          nodes[v].go[c] = 0;
        else
          nodes[v].go[c] = go(nodes[v].link, ch);
      }
    }
    return nodes[v].go[c];
  }
  Aho(vector<pair<string, long long>> &vs) {
    Node root = Node();
    nodes.push_back(root);
    for (auto s : vs) insert(s.first, s.second);
    queue<long long> fila;
    nodes[0].link = 0;
    for (long long &v : nodes[0].next) {
      if (v != -1) {
        fila.push(v);
        nodes[v].link = 0;
      } else
        v = 0;
    }
    while (!fila.empty()) {
      long long v = fila.front();
      fila.pop();
      for (long long u : nodes[v].next) {
        if (u != -1) {
          long long c = nodes[u].ch - 'a';
          long long fail = nodes[v].link;
          while (nodes[fail].next[c] == -1) {
            fail = nodes[fail].link;
          }
          fail = nodes[fail].next[c];
          nodes[u].v += nodes[fail].v;
          nodes[u].link = fail;
          fila.push(u);
        }
      }
    }
  }
  long long find(long long idx, long long p) {
    if (idx != p and (nodes[idx].leaf or idx == 0)) return idx;
    if (nodes[idx].superLink == -1) {
      nodes[idx].superLink = find(nodes[idx].link, p);
    }
    return nodes[idx].superLink;
  }
  vector<vector<long long>> findAll(string s, long long n) {
    vector<vector<long long>> res(n + 5);
    long long idx = 0;
    for (long long i = 0; i < (long long)s.size(); i++) {
      char ch = s[i];
      idx = go(idx, ch);
      long long aux = idx;
      while (aux) {
        if (nodes[aux].leaf) res[i + 1].push_back(nodes[aux].id);
        aux = find(aux, aux);
      }
    }
    return res;
  }
};
vector<vector<long long>> mult(vector<vector<long long>> a,
                               vector<vector<long long>> b) {
  vector<vector<long long>> c(
      (long long)a.size(),
      vector<long long>((long long)b.back().size(), -0x3f3f3f3f));
  for (long long i = 0; i < (long long)a.size(); i++) {
    for (long long j = 0; j < (long long)b.back().size(); j++) {
      for (long long k = 0; k < (long long)a.back().size(); k++) {
        c[i][j] = max(c[i][j], a[i][k] + b[k][j]);
      }
    }
  }
  return c;
}
vector<vector<long long>> pow(vector<vector<long long>> a, long long p) {
  if (p == 1) return a;
  if (p & 1) return mult(a, pow(a, p - 1));
  vector<vector<long long>> b = pow(a, p / 2);
  return mult(b, b);
}
long long n, l;
long long v[205];
int32_t main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin >> n >> l;
  string aux;
  vector<pair<string, long long>> vs;
  for (long long i = 1; i <= n; i++) cin >> v[i];
  for (long long i = 1; i <= n; i++) {
    cin >> aux;
    vs.push_back({aux, v[i]});
  }
  Aho ac = Aho(vs);
  long long tam = (long long)ac.nodes.size() + 5;
  vector<vector<long long>> m =
      vector<vector<long long>>(tam, vector<long long>(tam));
  for (long long i = 0; i < tam; i++) {
    for (long long j = 0; j < tam; j++) {
      m[i][j] = -0x3f3f3f3f;
    }
  }
  for (long long i = 0; i < tam; i++) {
    for (long long j = 0; j < 26; j++) {
      long long idx = ac.go(i, j + 'a');
      m[i][idx] = ac.nodes[idx].v;
    }
  }
  m = pow(m, l);
  long long res = 0;
  for (long long i = 0; i < tam; i++) {
    res = max(res, m[0][i]);
  }
  cout << res << '\n';
  return 0;
}