#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 5, M = 20;
int c[N];
int dp[1 << M];
int cnt[M];
int get(int x, int y) { return (x >> y) & 1; }
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      c[y] = i;
    }
  }
  for (int i = 1; i <= d; i++) {
    cnt[c[i]]++;
  }
  int mask = 0;
  for (int j = 0; j < m; j++) {
    if (cnt[j] == 0) {
      mask |= (1 << j);
    }
  }
  dp[mask]++;
  int p1 = 1, p2 = 1;
  for (int i = d + 1; i <= n; i++) {
    cnt[c[i]]++;
    cnt[c[i - d]]--;
    int mask = 0;
    for (int j = 0; j < m; j++) {
      if (cnt[j] == 0) {
        mask |= (1 << j);
      }
    }
    dp[mask]++;
  }
  for (int i = 0; i < m; i++) {
    for (int mask = 0; mask < (1 << m); mask++) {
      if (!get(mask, i)) {
        dp[mask] += dp[mask ^ (1 << i)];
      }
    }
  }
  int ans = m;
  for (int mask = 0; mask < (1 << m); mask++) {
    if (dp[mask] == 0) {
      ans = min(ans, __builtin_popcount(mask));
    }
  }
  cout << ans << endl;
  return 0;
}
