#include <bits/stdc++.h>
using namespace std;
int popcount(long long n) {
  int cnt = 0;
  for (; n; n &= n - 1) cnt++;
  return cnt;
}
int main() {
  int n, m;
  cin >> n >> m;
  int d;
  cin >> d;
  vector<int> id(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      x--;
      id[x] = i;
    }
  }
  vector<int> dp(1 << m);
  vector<int> cnt(m);
  for (int x = 0; x < n; x++) {
    cnt[id[x]]++;
    if (x >= d) cnt[id[x - d]]--;
    if (x >= d - 1) {
      int mask = 0;
      for (int i = 0; i < m; i++)
        if (cnt[i]) mask |= 1 << i;
      dp[mask] = true;
    }
  }
  for (int s = 0; s < 1 << m; s++) {
    for (int i = 0; i < m; i++) dp[s | 1 << i] |= dp[s];
  }
  int mi = m;
  for (int s = 0; s < 1 << m; s++) {
    if (!dp[s]) mi = min(mi, m - popcount(s));
  }
  cout << mi << endl;
  return 0;
}
