#include <bits/stdc++.h>
using namespace std;
const int MN = 202, MM = 20, MK = 505, MOD = 1000000007;
struct node {
  int val;
  node *c[MM], *jump[MM], *fail;
  node() {
    val = 0;
    memset(c, 0, sizeof c);
    memset(jump, 0, sizeof jump);
    fail = 0;
  }
  void add(const vector<int> &, int, int);
};
node xm[MN], *curx = xm;
node *new_node() {
  node *ret = curx++;
  return ret;
}
int get_id(node *x) { return x - xm; }
void node::add(const vector<int> &v, int val, int i = 0) {
  if (i == v.size()) {
    this->val += val;
    return;
  }
  if (c[v[i]] == NULL) c[v[i]] = new_node();
  c[v[i]]->add(v, val, i + 1);
}
node *get_next(node *cur, int x) {
  while (cur->c[x] == NULL) cur = cur->fail;
  return cur->c[x];
}
void bfs(node *root, int m) {
  queue<node *> q;
  int i;
  for (i = 0; i < m; ++i) {
    if (root->c[i] != NULL)
      q.push(root->c[i]), root->c[i]->fail = root;
    else
      root->c[i] = root;
  }
  node *cur;
  while (!q.empty()) {
    cur = q.front(), q.pop();
    for (i = 0; i < m; ++i) {
      if (cur->c[i] == NULL) continue;
      cur->c[i]->fail = get_next(cur->fail, i);
      cur->c[i]->val += cur->c[i]->fail->val;
      q.push(cur->c[i]);
    }
  }
  for (auto x = xm; x < curx; ++x) {
    for (i = 0; i < m; ++i) x->jump[i] = get_next(x, i);
  }
}
void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void take(int &a, int b) {
  a -= b;
  if (a < 0) a += MOD;
}
vector<int> l, r;
int memo[MN][MN][MK];
int get_count(int i, node *x, int k, bool trail, bool sameL, bool sameR,
              const int m) {
  if (k < 0) return 0;
  if (i == r.size()) return 1;
  bool save = !sameL && !sameR;
  int ret = 0, j;
  if (save) {
    ret = memo[i][get_id(x)][k];
    if (ret != -1) return ret;
    ret = 0;
  }
  node *cur;
  if (trail && l[i] <= 0 && r[i] >= 0) {
    add(ret, get_count(i + 1, x, k, true, sameL && (l[i] == 0),
                       sameR && (r[i] == 0), m));
  }
  for (j = trail; j < m; ++j) {
    if (sameL && j < l[i]) continue;
    if (sameR && j > r[i]) continue;
    cur = x->jump[j];
    add(ret, get_count(i + 1, cur, k - cur->val, false, sameL && (j == l[i]),
                       sameR && (j == r[i]), m));
  }
  if (save) memo[i][get_id(x)][k] = ret;
  return ret;
}
void read(vector<int> &v) {
  int len, i;
  scanf("%d", &len);
  v.resize(len);
  for (i = 0; i < len; ++i) scanf("%d", &v[i]);
}
int main() {
  int n, m, k, i;
  scanf("%d %d %d", &n, &m, &k);
  read(l), read(r);
  while (l.size() < r.size()) l.insert(l.begin(), 0);
  node *root = new_node();
  for (i = 0; i < n; ++i) {
    vector<int> v;
    read(v);
    int val;
    scanf("%d", &val);
    root->add(v, val);
  }
  bfs(root, m);
  int ans = 0;
  memset(memo, -1, sizeof memo);
  add(ans, get_count(0, root, k, true, true, true, m));
  printf("%d\n", ans);
  return 0;
}
