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;
const long long MIN = -1000000000000000000ll;
int n, a[205], nodes_count = 0;
long long l;
struct Node {
  Node *trans[26], *fail[26];
  int ind, hap;
  Node(void);
  Node *get_child(char ch) { return trans[ch - 'a']; }
  Node *get_failing(char ch) { return fail[ch - 'a']; }
  Node *get_either(char ch) {
    if (get_child(ch) != NULL) return get_child(ch);
    return get_failing(ch);
  }
  bool has_child(char ch) { return get_child(ch) != NULL; }
  void set_child(char ch, Node *node) { trans[ch - 'a'] = node; }
  void set_failing(char ch, Node *node) { fail[ch - 'a'] = node; }
  Node *expand_child(char ch) {
    if (!has_child(ch)) set_child(ch, new Node());
    return get_child(ch);
  }
};
Node *all_nodes[205];
Node::Node(void) {
  hap = 0;
  ind = nodes_count;
  all_nodes[nodes_count++] = this;
  for (int i = 0; i < 26; ++i) trans[i] = fail[i] = NULL;
}
struct Trie {
  Node *root;
  Trie() { root = new Node(); }
  void insert(string s, int val) {
    Node *node = root;
    for (int i = 0; i < s.size(); ++i) node = node->expand_child(s[i]);
    node->hap += val;
  }
  Node *find_prefix(string s) {
    Node *node = root;
    for (int i = 0; i < s.size(); ++i) {
      if (!node->has_child(s[i])) return NULL;
      node = node->get_child(s[i]);
    }
    return node;
  }
  void build_failing(Node *node, string prefix) {
    for (char ch = 'a'; ch <= 'z'; ++ch) {
      string tmp = prefix;
      tmp.push_back(ch);
      if (node->has_child(ch)) {
        build_failing(node->get_child(ch), tmp);
      } else {
        for (int i = 1; i <= tmp.size(); ++i) {
          Node *back_node = find_prefix(tmp.substr(i));
          if (back_node != NULL) {
            node->set_failing(ch, back_node);
            break;
          }
        }
      }
    }
  }
  void add_haps(void) {
    deque<pair<Node *, string> > Q;
    Q.push_back(make_pair(root, ""));
    while (!Q.empty()) {
      Node *node = Q.front().first;
      string prefix = Q.front().second;
      Q.pop_front();
      for (int i = 1; i <= prefix.size(); ++i) {
        Node *back_node = find_prefix(prefix.substr(i));
        if (back_node != NULL) {
          node->hap += back_node->hap;
          break;
        }
      }
      for (char ch = 'a'; ch <= 'z'; ++ch)
        if (node->has_child(ch)) {
          string tmp = prefix;
          tmp.push_back(ch);
          Q.push_back(make_pair(node->get_child(ch), tmp));
        }
    }
  }
} T;
struct Matrix {
  long long data[205][205];
  Matrix() {
    for (int i = 0; i < 205; ++i)
      for (int j = 0; j < 205; ++j) data[i][j] = MIN;
  }
} M;
struct Column {
  long long data[205];
  Column() {
    for (int i = 0; i < 205; ++i) data[i] = MIN;
  }
} col;
Matrix operator*(const Matrix &A, const Matrix &B) {
  Matrix C;
  for (int i = 0; i < nodes_count; ++i)
    for (int j = 0; j < nodes_count; ++j)
      for (int k = 0; k < nodes_count; ++k)
        C.data[i][j] = max(C.data[i][j], A.data[i][k] + B.data[k][j]);
  return C;
}
Column operator*(const Matrix &A, const Column &B) {
  Column C;
  for (int i = 0; i < nodes_count; ++i)
    for (int j = 0; j < nodes_count; ++j)
      C.data[i] = max(C.data[i], A.data[i][j] + B.data[j]);
  return C;
}
Matrix power(const Matrix &B, long long p) {
  if (p == 1) return B;
  Matrix R = power(B, p / 2);
  R = R * R;
  if (p % 2) R = R * B;
  return R;
}
void print_matrix(const Matrix &M) {
  for (int i = 0; i < nodes_count; ++i) {
    for (int j = 0; j < nodes_count; ++j)
      if (M.data[i][j] < 0)
        cout << "- ";
      else
        cout << M.data[i][j] << " ";
    cout << endl;
  }
}
void print_column(const Column &col) {
  for (int i = 0; i < nodes_count; ++i) {
    if (col.data[i] < 0)
      cout << "- ";
    else
      cout << col.data[i] << " ";
    cout << endl;
  }
}
int main(void) {
  cin >> n >> l;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    T.insert(s, a[i]);
  }
  T.build_failing(T.root, "");
  T.add_haps();
  for (int i = 0; i < nodes_count; ++i)
    for (int j = 0; j < nodes_count; ++j) {
      long long hap = MIN;
      for (char ch = 'a'; ch <= 'z'; ++ch) {
        Node *tmp = all_nodes[i]->get_either(ch);
        if (tmp->ind == j) hap = tmp->hap;
      }
      M.data[j][i] = hap;
    }
  Matrix R = power(M, l);
  col.data[0] = 0;
  col = R * col;
  long long result = MIN;
  for (int i = 0; i < nodes_count; ++i) result = max(result, col.data[i]);
  cout << result << endl;
  return 0;
}