#include <bits/stdc++.h>
using namespace std;
int m, k;
int ch[210][20], sz, val[210];
void insert(int *num, int v) {
  int u = 0;
  for (int i = 1; i <= num[0]; i++) {
    if (!ch[u][num[i]]) ch[u][num[i]] = ++sz;
    u = ch[u][num[i]];
  }
  val[u] += v;
}
int fa[210], fr, rr, q[210];
void calc_fa() {
  fr = 0, rr = -1;
  for (int i = 0; i < m; i++)
    if (ch[0][i]) q[++rr] = ch[0][i];
  while (fr <= rr) {
    int r = q[fr++];
    for (int i = 0; i < m; i++) {
      int u = ch[r][i];
      if (!u) {
        ch[r][i] = ch[fa[r]][i];
        continue;
      }
      fa[u] = ch[fa[r]][i];
      val[u] += val[fa[u]];
      q[++rr] = u;
    }
  }
}
int d[210][210][510];
int dp(int u, int L, int v) {
  if (v < 0) return 0;
  if (L == 0) return 1;
  if (d[u][L][v] != -1) return d[u][L][v];
  d[u][L][v] = 0;
  for (int i = 0; i <= m - 1; i++) {
    d[u][L][v] += dp(ch[u][i], L - 1, v - val[ch[u][i]]);
    d[u][L][v] %= 1000000007;
  }
  return d[u][L][v];
}
int calc(int *dig) {
  int ret = 0, u = 0;
  for (int i = 1; i < dig[0]; i++) {
    for (int j = 1; j <= m - 1; j++) {
      ret += dp(ch[u][j], i - 1, k - val[ch[u][j]]);
      ret %= 1000000007;
    }
  }
  int sum = 0;
  for (int i = dig[0]; i; i--) {
    for (int j = (i == dig[0] ? 1 : 0); j < dig[i]; j++) {
      ret += dp(ch[u][j], i - 1, k - sum - val[ch[u][j]]);
      ret %= 1000000007;
    }
    u = ch[u][dig[i]];
    sum += val[u];
    if (sum > k) break;
  }
  return (ret + (sum <= k)) % 1000000007;
}
int l[210], r[210];
int n, num[210];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  scanf("%d", &l[0]);
  for (int i = 1; i <= l[0]; i++) scanf("%d", &l[i]);
  reverse(l + 1, l + l[0] + 1);
  scanf("%d", &r[0]);
  for (int i = 1; i <= r[0]; i++) scanf("%d", &r[i]);
  reverse(r + 1, r + r[0] + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[0]);
    for (int j = 1; j <= num[0]; j++) scanf("%d", &num[j]);
    int v;
    scanf("%d", &v);
    insert(num, v);
  }
  calc_fa();
  int tmp = 0, u = 0;
  for (int i = l[0]; i >= 1; i--) {
    u = ch[u][l[i]];
    tmp += val[u];
  }
  memset(d, -1, sizeof(d));
  printf("%d", ((calc(r) - calc(l) + (tmp <= k)) % 1000000007 + 1000000007) %
                   1000000007);
  return 0;
}
