func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 505, MOD = 1e9 + 7;   struct node {     node *ch[20], *fail;     int cnt, id;     node(node* son = NULL) {       for (int i = 0; i <= 19; i++) ch[i] = son;       fail = son;       cnt = id = 0;     }   } nil, *null = &nil, *root = null, *nd[maxn];   typedef node* P_node;   queue<P_node> que;   void Build() {     root->fail = root;     root->id = 0;     nd[0] = root;     for (int i = 0; i <= 19; i++)       if (root->ch[i] != null) {         P_node v = root->ch[i];         que.push(v);         v->fail = root;       } else         root->ch[i] = root;     while (!que.empty()) {       P_node p = que.front();       que.pop();       for (int i = 0; i <= 19; i++)         if (p->ch[i] != null) {           P_node v = p->ch[i];           que.push(v);           v->fail = p->fail->ch[i];           v->cnt += v->fail->cnt;         } else           p->ch[i] = p->fail->ch[i];     }   }   int a[maxn], b[maxn], c[maxn], n, m, K, tot;   int f[2][205][705][2][2];   int Calc(int a[]) {     memset(f, 0, sizeof(f));     f[0][0][0][0][0] = 1;     for (int i = 0, o = 0; i <= a[0] - 1; i++, o ^= 1) {       memset(f[o ^ 1], 0, sizeof(f[o ^ 1]));       for (int j = 0; j <= tot; j++)         for (int k = 0; k <= K; k++)           for (int t1 = 0; t1 <= 1; t1++)             for (int t2 = 0; t2 <= 1; t2++)               if (f[o][j][k][t1][t2]) {                 for (int t = 0; t <= (t2 ? m - 1 : a[i + 1]); t++) {                   int v = (t1 | (t > 0)) ? nd[j]->ch[t]->id : 0;                   (f[o ^ 1][v][k + nd[v]->cnt][t1 | (t > 0)]                     [t2 | (t < a[i + 1])] += f[o][j][k][t1][t2]) %= MOD;                 }               }     }     int res = 0;     for (int i = 0; i <= tot; i++)       for (int j = 0; j <= K; j++)         for (int k = 0; k <= 1; k++)           for (int t = 0; t <= 1; t++) (res += f[a[0] & 1][i][j][k][t]) %= MOD;     return res;   }   int main() {     scanf( %d%d%d , &n, &m, &K);     scanf( %d , &a[0]);     for (int i = 1; i <= a[0]; i++) scanf( %d , &a[i]);     scanf( %d , &b[0]);     for (int i = 1; i <= b[0]; i++) scanf( %d , &b[i]);     a[a[0]]--;     for (int i = a[0]; i >= 1; i--)       if (a[i] < 0) a[i] += m, a[i - 1]--;     nil = node(null);     for (int i = 1; i <= n; i++) {       int t, x;       scanf( %d , &t);       P_node now = root;       while (t--) {         scanf( %d , &x);         if (now->ch[x] == null) {           now = now->ch[x] = new node(null);           now->id = ++tot;           nd[tot] = now;         } else           now = now->ch[x];       }       scanf( %d , &x);       now->cnt += x;     }     Build();     printf( %d n , ((Calc(b) - Calc(a)) % MOD + MOD) % MOD);     return 0;   }   