func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int MAXN = 205;   const int infint = 1e9;   const long long inf = 1e18;   const int K = 26;   long long n, l, a[MAXN], nxt[MAXN][K], used[MAXN];   string s[MAXN];   struct Vertex {     int next[K];     bool leaf = false;     long long val = 0;     int p = -1;     char pch;     int f = -1;     int go[K];     Vertex(int p = -1, char ch =  $ ) : p(p), pch(ch) {       memset(next, -1, sizeof next);       memset(go, -1, sizeof go);     }   };   vector<Vertex> t(1);   void add_string(string const &s, int value) {     int v = 0;     for (int i = 0; i < s.size(); i++) {       int c = s[i] -  a ;       if (t[v].next[c] == -1) {         t[v].next[c] = t.size();         Vertex child = Vertex(v, s[i]);         t.push_back(child);       }       v = t[v].next[c];     }     t[v].leaf = 1;     t[v].val += value;   }   int go(int v, char ch);   int get_link(int v) {     if (t[v].f == -1) {       if (v == 0 || t[v].p == 0)         t[v].f = 0;       else         t[v].f = go(get_link(t[v].p), t[v].pch);     }     return t[v].f;   }   int go(int v, char ch) {     int c = ch -  a ;     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), ch);     }     return t[v].go[c];   }   void upd(int c) {     if (used[c]) return;     used[c] = 1;     if (c == 0) return;     upd(t[c].f);     t[c].val += t[t[c].f].val;   }   struct matrix {     long long a[MAXN][MAXN], n, m;     matrix(long long Cn, long long Cm) {       n = Cn, m = Cm;       for (long long i = 0; i < n; i++)         for (long long j = 0; j < m; j++) a[i][j] = -infint;     }     long long *operator[](const long long &i) { return a[i]; }     matrix Identity(const long long &n) {       matrix c(n, m);       return c;     }     inline matrix operator*(matrix &b) {       matrix c(n, b.m);       for (int i = 0; i < n; i++)         for (int j = 0; j < b.m; j++)           for (int k = 0; k < m; k++)             if (a[i][k] >= 0 && b[k][j] >= 0)               c[i][j] = max(c[i][j], (long long)a[i][k] + (long long)b[k][j]);       return c;     }     inline matrix operator+(matrix b) {       matrix c(n, m);       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++) c[i][j] = (a[i][j] + b[i][j]) % MOD;       return c;     }     matrix operator^(const long long &c) {       if (c == 0) return Identity(n);       if (c == 1) return *this;       matrix tmp = *this ^ (c >> 1);       tmp = tmp * tmp;       if (c & 1) tmp = tmp * *this;       return tmp;     }     void inline print() {       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) cout << a[i][j] <<    ;         cout <<   n ;       }     }   };   matrix cost(MAXN, MAXN);   matrix base(1, MAXN);   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> l;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) add_string(s[i], a[i]);     for (int i = 0; i < t.size(); i++)       for (int j = 0; j < K; j++) nxt[i][j] = go(i, (char)(j +  a ));     for (int i = 1; i < t.size(); i++) upd(i);     cost.n = cost.m = t.size();     for (int i = 0; i < t.size(); i++)       for (int j = 0; j < t.size(); j++) cost[i][j] = -inf;     for (int i = 0; i < t.size(); i++)       for (int j = 0; j < K; j++) cost[i][nxt[i][j]] = t[nxt[i][j]].val;     cost = cost ^ l;     base.n = 1;     base.m = t.size();     base[0][0] = 0;     for (int i = 1; i < t.size(); i++) base[0][i] = -inf;     base = base * cost;     long long ans = 0;     for (int i = 0; i < t.size(); i++) ans = max(ans, base[0][i]);     cout << ans;   }   