#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m, d, cnt, num, ans, sta, a[1 << 21], k[maxn], fal[1 << 21];
int main(void) {
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 0; i < m; i++) {
    scanf("%d", &cnt);
    while (cnt--) {
      scanf("%d", &num);
      k[num] = i;
    }
  }
  ans = m + 1;
  for (int i = 1; i < d; i++) a[k[i]]++;
  for (int i = d; i <= n; i++) {
    if (i > d) a[k[i - d]]--;
    a[k[i]]++;
    sta = 0;
    for (int j = 0; j < m; j++)
      if (!a[j]) sta |= (1 << j);
    fal[sta] = 1;
  }
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (fal[i]) {
      for (int j = 0; j < m; j++)
        if (i & (1 << j)) fal[i ^ (1 << j)] = 1;
    } else {
      cnt = 0;
      for (int j = 0; j < m; j++)
        if (i & (1 << j)) cnt++;
      ans = min(ans, cnt);
    }
  }
  printf("%d\n", ans);
  return 0;
}
