#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, d;
  cin >> n >> m >> d;
  vector<int> col(n);
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    for (int j = 0; j < s; j++) {
      int a;
      cin >> a;
      a--;
      col[a] = i;
    }
  }
  int msk = (1 << m) - 1;
  vector<bool> bad(1 << m, false);
  vector<int> cnt(m, 0);
  for (int i = 0; i < d; i++) {
    cnt[col[i]]++;
    if (msk & (1 << col[i])) msk -= (1 << col[i]);
  }
  bad[msk] = true;
  for (int i = d; i < n; i++) {
    cnt[col[i]]++;
    if (msk & (1 << col[i])) msk -= (1 << col[i]);
    cnt[col[i - d]]--;
    if (cnt[col[i - d]] == 0) msk += (1 << col[i - d]);
    bad[msk] = true;
  }
  int mn = m;
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (!bad[i]) {
      mn = min(mn, __builtin_popcount(i));
      continue;
    }
    for (int j = 0; j < m; j++) {
      if (i & (1 << j)) bad[i - (1 << j)] = true;
    }
  }
  cout << mn << "\n";
}
