#include <bits/stdc++.h>
using namespace std;
const int KIND = 20;
int n, m, k;
const int MOD = 1000000007;
int dp[222][222][500];
struct Node {
  int child[KIND], fail, val;
  Node() {}
  void init() {
    memset(child, 0, sizeof(child));
    fail = val = 0;
  }
} node[222];
struct Trie {
  int root, alloc;
  Trie() {}
  void clear() {
    root = alloc = 0;
    node[root].init();
  }
  void insert(const vector<int> &str, int val) {
    int p = root;
    for (int i = 0; i < str.size(); i++) {
      if (!node[p].child[str[i]]) {
        node[p].child[str[i]] = ++alloc;
        node[alloc].init();
      }
      p = node[p].child[str[i]];
    }
    node[p].val += val;
  }
  void build() {
    queue<int> que;
    que.push(root);
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      int ufail = node[u].fail;
      for (int i = 0; i < m; i++) {
        int v = node[u].child[i];
        if (v) {
          if (u != root) {
            node[v].fail = node[ufail].child[i];
          } else {
            node[v].fail = root;
          }
          node[v].val += node[node[v].fail].val;
          que.push(v);
        } else {
          node[u].child[i] = node[ufail].child[i];
        }
      }
    }
  }
} trie;
void read(vector<int> &vec) {
  int len;
  cin >> len;
  vec.resize(len);
  for (int i = 0; i < len; i++) cin >> vec[i];
}
int add(int a, int b) { return (a + b) % MOD; }
vector<int> l, r;
int dfs(int i, int pos, int sum, bool L, bool R, bool flag) {
  if (sum > k) return 0;
  if (i == r.size()) {
    return 1;
  }
  if (!L && !R && dp[i][pos][sum] != -1) {
    return dp[i][pos][sum];
  }
  int res = 0;
  for (int d = 0; d < m; d++) {
    if (L && d < l[i]) continue;
    if (R && d > r[i]) continue;
    int npos;
    if (flag && d == 0)
      npos = pos;
    else
      npos = node[pos].child[d];
    res = add(res, dfs(i + 1, npos, sum + node[npos].val, L && (d == l[i]),
                       R && (d == r[i]), flag && (d == 0)));
  }
  return !L && !R ? dp[i][pos][sum] = res : res;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  read(l);
  read(r);
  while (l.size() < r.size()) l.insert(l.begin(), 0);
  trie.clear();
  for (int i = 0; i < n; i++) {
    vector<int> str;
    read(str);
    int val;
    cin >> val;
    trie.insert(str, val);
  }
  trie.build();
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, 0, 0, 1, 1, 1) << endl;
  return 0;
}
