#include <bits/stdc++.h>
using namespace std;
const int N = 205;
const int MOD = 1000000007;
struct Trie {
  Trie *next[20], *fail;
  int val;
} * root, s[N], *que[N];
int n, m, k, tot;
Trie *NewNode() {
  Trie *p = &s[tot++];
  memset(p->next, NULL, sizeof(p->next));
  p->fail = NULL;
  p->val = 0;
  return p;
}
void insert(vector<int> &a, int v) {
  Trie *p = root;
  for (int i = 0; i < a.size(); i++) {
    int c = a[i];
    if (p->next[c] == NULL) p->next[c] = NewNode();
    p = p->next[c];
  }
  p->val += v;
}
void build() {
  int head = 0, tail = 0;
  que[tail++] = root;
  while (head < tail) {
    Trie *p = que[head++];
    for (int i = 0; i < m; i++) {
      if (p->next[i]) {
        if (p == NULL)
          p->next[i]->fail = root;
        else {
          Trie *q = p->fail;
          while (q) {
            if (q->next[i]) {
              p->next[i]->fail = q->next[i];
              break;
            }
            q = q->fail;
          }
          if (q == NULL) p->next[i]->fail = root;
        }
        p->next[i]->val += p->next[i]->fail->val;
        que[tail++] = p->next[i];
      } else if (p == root)
        p->next[i] = root;
      else
        p->next[i] = p->fail->next[i];
    }
  }
}
vector<int> read() {
  vector<int> v;
  int len, k;
  scanf("%d", &len);
  for (int j = 0; j < len; j++) {
    scanf("%d", &k);
    v.push_back(k);
  }
  return v;
}
void sub(vector<int> &v) {
  int p = v.size() - 1;
  while (true) {
    if (v[p] == 0) {
      v[p] = m - 1;
    } else {
      v[p]--;
      break;
    }
    p--;
  }
}
vector<int> l, r, a;
int dp[N][N][505][2];
int dfs(int l, int node, int val, int zero, int lim) {
  if (val > k) return 0;
  if (l < 0) {
    return val <= k;
  }
  if (!lim && dp[l][node][val][zero] != -1) return dp[l][node][val][zero];
  int up = lim ? a[l] : (m - 1), ret = 0;
  for (int i = 0; i <= up; i++) {
    int nxt;
    if (zero && i == 0)
      nxt = 0;
    else
      nxt = s[node].next[i] - s;
    ret = (ret +
           dfs(l - 1, nxt, val + s[nxt].val, zero && i == 0, lim && i == up)) %
          MOD;
  }
  if (!lim) dp[l][node][val][zero] = ret;
  return ret;
}
int gao(vector<int> &v) {
  a = v;
  reverse(a.begin(), a.end());
  return dfs(a.size() - 1, 0, 0, 1, 1);
}
int main() {
  tot = 0;
  root = NewNode();
  scanf("%d %d %d", &n, &m, &k);
  l = read();
  r = read();
  for (int i = 0; i < n; i++) {
    vector<int> v = read();
    int k;
    scanf("%d", &k);
    insert(v, k);
  }
  build();
  memset(dp, -1, sizeof(dp));
  sub(l);
  printf("%d\n", (gao(r) - gao(l) + MOD) % MOD);
  return 0;
}
