#include <bits/stdc++.h>
using namespace std;
const int N = 201;
const int mod = 1e9 + 7;
int n, m, k;
struct AC_Automata {
  int root, tree[N][20], tot;
  int fail[N], val[N];
  int qu[N], head, tail;
  int newnode() {
    for (int i = 0; i < m; i++) tree[tot][i] = 0;
    fail[tot] = val[tot] = 0;
    return tot++;
  }
  void init() {
    tot = 0;
    root = newnode();
  }
  void insert(vector<int> &s, int _val) {
    int cur = root;
    for (int i = 1; i < (int)s.size(); i++) {
      int tmp = s[i];
      if (!tree[cur][tmp]) tree[cur][tmp] = newnode();
      cur = tree[cur][tmp];
    }
    val[cur] += _val;
  }
  void build() {
    head = 1, tail = 0;
    for (int i = 0; i < m; i++)
      if (tree[0][i]) qu[++tail] = tree[0][i];
    while (head <= tail) {
      int cur = qu[head++];
      for (int i = 0; i < m; i++) {
        int tmp = tree[cur][i];
        if (tmp)
          fail[tmp] = tree[fail[cur]][i], qu[++tail] = tmp;
        else
          tree[cur][i] = tree[fail[cur]][i];
      }
    }
    for (int i = 1; i <= tail; i++) val[qu[i]] += val[fail[qu[i]]];
  }
  int query(vector<int> &s) {
    int cur = root, _val = 0;
    for (int i = 1; i < (int)s.size(); i++) {
      cur = tree[cur][s[i]];
      _val += val[cur];
    }
    return _val;
  }
} ac;
vector<int> nums;
int dp[201][201][501];
int DP(int pos, int st, int sum, bool lim, bool lead) {
  if (pos == 0) return 1;
  if (!lim && !lead && dp[pos][st][sum] != -1) return dp[pos][st][sum];
  int ans = 0, up = lim ? nums[pos] : (m - 1);
  for (int i = 0; i <= up; i++) {
    if (lead && i == 0)
      ans = (ans + DP(pos - 1, 0, 0, lim && i == nums[pos], true)) % mod;
    else {
      int tmp = ac.tree[st][i];
      if (sum + ac.val[tmp] > k) continue;
      ans = (ans + DP(pos - 1, tmp, sum + ac.val[tmp], lim && i == nums[pos],
                      lead && i == 0)) %
            mod;
    }
  }
  if (!lim && !lead) dp[pos][st][sum] = ans;
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  auto read = [&]() -> vector<int> {
    vector<int> v;
    int len;
    scanf("%d", &len);
    v.emplace_back(len);
    for (int i = 1; i <= len; i++) {
      int val;
      scanf("%d", &val);
      v.emplace_back(val);
    }
    return v;
  };
  vector<int> l = read(), r = read();
  ac.init();
  for (int i = 1; i <= n; i++) {
    vector<int> v = read();
    int val;
    scanf("%d", &val);
    ac.insert(v, val);
  }
  ac.build();
  memset(dp, -1, sizeof dp);
  nums = r;
  reverse(nums.begin() + 1, nums.end());
  int ans = DP(nums[0], 0, 0, 1, 1);
  nums = l;
  reverse(nums.begin() + 1, nums.end());
  ans = (ans - DP(nums[0], 0, 0, 1, 1)) % mod;
  if (ac.query(l) <= k) ans++;
  ans = (ans + mod) % mod;
  printf("%d\n", ans);
  return 0;
}
