#include <bits/stdc++.h>
using namespace std;
int arr[100000];
int cnt[20];
bool mask[(1 << 20) | 1];
int main() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 0; i < m; i++) {
    int s;
    scanf("%d", &s);
    while (s--) {
      int x;
      scanf("%d", &x);
      arr[x - 1] = i;
    }
  }
  int tmp = (1 << m) - 1;
  for (int i = 0; i < d; i++) {
    cnt[arr[i]]++;
    if (cnt[arr[i]] == 1) tmp ^= (1 << arr[i]);
  }
  mask[tmp] = true;
  for (int i = 1; i + d - 1 < n; i++) {
    cnt[arr[i - 1]]--;
    if (cnt[arr[i - 1]] == 0) tmp ^= (1 << arr[i - 1]);
    cnt[arr[i + d - 1]]++;
    if (cnt[arr[i + d - 1]] == 1) tmp ^= (1 << arr[i + d - 1]);
    mask[tmp] = true;
  }
  int ans = m;
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (mask[i]) {
      for (int j = 0; j < m; j++) {
        if (i & (1 << j)) mask[i ^ (1 << j)] = true;
      }
    } else {
      ans = min(ans, __builtin_popcount(i));
    }
  }
  printf("%d", ans);
}
