#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m, K;
int L[205], R[205], str[205];
struct node {
  node *next[20];
  node *fail;
  int id, val;
} pool[205], *root;
int tot = 0;
inline node *newnode() {
  node *t = pool + tot;
  t->id = tot++;
  memset(t->next, 0, sizeof(t->next));
  t->val = 0;
  t->fail = NULL;
  return t;
}
inline void Insert(int *d, int v) {
  node *p = root;
  for (int i = 1; i <= d[0]; ++i) {
    if (!p->next[d[i]]) p->next[d[i]] = newnode();
    p = p->next[d[i]];
  }
  p->val += v;
}
queue<node *> Q;
void bfs() {
  while (!Q.empty()) Q.pop();
  node *p, *temp;
  Q.push(root);
  while (!Q.empty()) {
    temp = Q.front();
    Q.pop();
    for (int i = 0; i < m; ++i)
      if (temp->next[i]) {
        if (temp == root)
          temp->next[i]->fail = root;
        else {
          p = temp->fail;
          while (p) {
            if (p->next[i]) {
              temp->next[i]->fail = p->next[i];
              temp->next[i]->val += p->next[i]->val;
              break;
            }
            p = p->fail;
          }
          if (!p) temp->next[i]->fail = root;
        }
        Q.push(temp->next[i]);
      } else {
        if (temp == root)
          temp->next[i] = root;
        else
          temp->next[i] = temp->fail->next[i];
      }
  }
}
int dp[205][205][505];
int solve(int pos, int st, int val, bool up, bool down, bool Lead_zero) {
  val += pool[st].val;
  if (val > K) return 0;
  if (pos > R[0]) return 1;
  if (!up && !down && dp[pos][st][val] != -1) return dp[pos][st][val];
  int res = 0;
  for (int i = 0; i < m; ++i) {
    if (up && i > R[pos]) continue;
    if (down && i < L[pos]) continue;
    int nst = st;
    if (!Lead_zero || i > 0) nst = pool[st].next[i]->id;
    res += solve(pos + 1, nst, val, up && i == R[pos], down && i == L[pos],
                 Lead_zero && i == 0);
    if (res >= mod) res -= mod;
  }
  if (!up && !down) dp[pos][st][val] = res;
  return res;
}
inline void shift(int len) {
  for (int i = len; i >= 2; --i) L[i] = L[i - 1];
  L[1] = 0;
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  scanf("%d", L);
  for (int i = 1; i <= L[0]; ++i) scanf("%d", L + i);
  scanf("%d", R);
  for (int i = 1; i <= R[0]; ++i) scanf("%d", R + i);
  while (L[0] < R[0]) shift(++L[0]);
  root = newnode();
  for (int i = 0; i < n; ++i) {
    int v;
    scanf("%d", str);
    for (int i = 1; i <= str[0]; ++i) scanf("%d", str + i);
    scanf("%d", &v);
    Insert(str, v);
  }
  bfs();
  memset(dp, -1, sizeof(dp));
  printf("%d\n", solve(1, 0, 0, 1, 1, 1));
  return 0;
}
