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>
struct Matrix {
  static const int MAXN = 200;
  int N, M;
  long long A[MAXN + 5][MAXN + 5];
  Matrix() {
    N = M = 0;
    memset(A, 0, sizeof A);
  }
  Matrix(int row, int col, int sign = 0) : N(row), M(col) {
    memset(A, 0, sizeof A);
    for (int i = 1; i <= row; i++)
      for (int j = 1; j <= col; j++) A[i][j] = sign;
  }
  long long *operator[](const int &i) { return A[i]; }
  Matrix operator*(Matrix &B) {
    Matrix ret(N, B.M, -1);
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= M; j++)
        for (int k = 1; k <= B.N; k++)
          if (A[i][k] != -1 && B[k][j] != -1)
            ret[i][j] = std::max(ret[i][j], A[i][k] + B[k][j]);
    return ret;
  }
  void Output() {
    puts("");
    puts("-- Debug --");
    printf("\t");
    for (int i = 1; i <= N; i++) printf("(%d)\t", i);
    for (int i = 1; i <= N; i++) {
      printf("\n(%d)\t", i);
      for (int j = 1; j <= M; j++) printf("%lld\t", A[i][j]);
    }
    puts("");
  }
  Matrix operator^(long long y) {
    Matrix ret(N, N, -1), base = *this;
    ret[1][1] = 0;
    while (y) {
      if (y & 1) ret = ret * base;
      y >>= 1;
      base = base * base;
    }
    return ret;
  }
};
struct AC_Automaton {
  static const int MAXC = 26;
  static const int MAXL = 200;
  struct Node {
    char dbg;
    int num;
    int ch[MAXC + 5], fal;
  } T[MAXL + 5];
  int NodeCnt;
  AC_Automaton() {
    NodeCnt = 1, T[1].dbg = '$';
    memset(T, 0, sizeof T);
  }
  int NewNode(const char &cur) {
    T[++NodeCnt].dbg = cur;
    return NodeCnt;
  }
  void Insert(const char *str, const int &hps) {
    int len = strlen(str), u = 1;
    for (int i = 0; i < len; i++) {
      int id = str[i] - 'a';
      if (!T[u].ch[id]) T[u].ch[id] = NewNode(str[i]);
      u = T[u].ch[id];
    }
    T[u].num += hps;
  }
  void GetFail() {
    std::queue<int> Q;
    for (int i = 1; i <= NodeCnt; i++) T[i].fal = 1;
    for (int i = 0; i < MAXC; i++)
      if (T[1].ch[i])
        Q.push(T[1].ch[i]);
      else
        T[1].ch[i] = 1;
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      T[u].num += T[T[u].fal].num;
      for (int i = 0; i < MAXC; i++) {
        int v = T[u].ch[i], nxt = T[T[u].fal].ch[i];
        if (v) {
          Q.push(v);
          T[v].fal = nxt;
        } else
          T[u].ch[i] = nxt;
      }
    }
  }
};
const int MAXN = 200;
int N;
long long L;
int A[MAXN + 5];
char tmp[MAXN + 5];
int main() {
  scanf("%d%lld", &N, &L);
  for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
  AC_Automaton Trie;
  for (int i = 1; i <= N; i++) {
    scanf("%s", tmp);
    Trie.Insert(tmp, A[i]);
  }
  Trie.GetFail();
  Matrix dp(Trie.NodeCnt, Trie.NodeCnt, -1);
  for (int i = 1; i <= Trie.NodeCnt; i++)
    for (int j = 0; j < AC_Automaton::MAXC; j++) {
      int v = Trie.T[i].ch[j];
      dp[i][v] = Trie.T[v].num;
    }
  dp = dp ^ L;
  long long Ans = 0;
  for (int j = 1; j <= dp.M; j++) Ans = std::max(Ans, dp[1][j]);
  printf("%lld", Ans);
  return 0;
}