#include <bits/stdc++.h>
using namespace std;
struct Numb {
  int len, k[205];
  void init() {
    scanf("%d", &len);
    for (int i = 1; i <= len; i++) scanf("%d", &k[i]);
  }
} L, R, p[205];
int N, M, K, P;
int val[205], ans;
int dp[205][3][205][505];
queue<int> q;
struct ACtrie {
  int son[205][25], pt;
  int next[205], have[205];
  void Insert(int x) {
    int i, now = 0, tmp;
    for (i = 1; i <= p[x].len; i++) {
      tmp = p[x].k[i];
      if (!son[now][tmp]) {
        pt++;
        memset(son[pt], 0, sizeof(pt));
        son[now][tmp] = pt;
      }
      now = son[now][tmp];
    }
    have[now] += val[x];
  }
  void Work() {
    int i, tmp, x, t;
    for (i = 0; i < M; i++)
      if (son[0][i]) q.push(son[0][i]);
    while (!q.empty()) {
      x = q.front(), q.pop();
      for (i = 0; i < M; i++)
        if (son[x][i]) {
          t = next[x], tmp = son[x][i];
          while (t && !son[t][i]) t = next[t];
          next[tmp] = son[t][i], have[tmp] += have[son[t][i]];
          q.push(tmp);
        } else
          son[x][i] = son[next[x]][i];
    }
  }
} S;
void Add(int& a, int b) { a = (a + b) % 1000000007; }
int Ask(Numb x, int flag) {
  int i, j, t, k, s;
  int len = x.len, tmp, sc;
  int tt, jj, kk;
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0] = 1;
  for (i = 0; i < len; i++)
    for (j = 0; j <= 2; j++)
      for (t = 0; t <= P; t++)
        for (k = 0; k <= K; k++)
          if ((sc = dp[i][j][t][k]) != 0) {
            for (s = 0; s < M; s++) {
              if (j == 1 && s > x.k[i + 1]) break;
              if (j == 0 && i == 0 && s > x.k[i + 1]) break;
              if (j) {
                jj = min(2, j + (s < x.k[i + 1]));
                tt = S.son[t][s];
              } else if (s == 0)
                jj = tt = 0;
              else {
                jj = 1 + ((i != 0) || (s < x.k[i + 1]));
                tt = S.son[t][s];
              }
              kk = k + S.have[tt];
              if (kk <= K) Add(dp[i + 1][jj][tt][kk], sc);
            }
          }
  sc = 0;
  for (t = 0; t <= P; t++)
    for (k = 0; k <= K; k++) {
      Add(sc, flag * dp[len][1][t][k]);
      Add(sc, dp[len][2][t][k]);
    }
  return sc;
}
int main() {
  int i, j;
  scanf("%d %d %d", &N, &M, &K);
  L.init(), R.init();
  for (i = 1; i <= N; i++) {
    p[i].init();
    scanf("%d", &val[i]);
    S.Insert(i);
  }
  S.Work(), P = S.pt;
  printf("%d\n", (Ask(R, 1) - Ask(L, 0) + 1000000007) % 1000000007);
  return 0;
}
