#include <bits/stdc++.h>
unsigned popcount(unsigned u) {
  u = (u & 0x55555555) + ((u >> 1) & 0x55555555);
  u = (u & 0x33333333) + ((u >> 2) & 0x33333333);
  u = (u & 0x0F0F0F0F) + ((u >> 4) & 0x0F0F0F0F);
  u = (u & 0x00FF00FF) + ((u >> 8) & 0x00FF00FF);
  u = (u & 0x0000FFFF) + ((u >> 16) & 0x0000FFFF);
  return u;
}
using namespace std;
int rr[100001];
bool check[1 << 20];
int temp[20];
int main() {
  int n, m, d, s, a;
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 0; i < m; i++) {
    scanf("%d", &s);
    for (int j = 0; j < s; j++) scanf("%d", &a), rr[a] = i;
  }
  for (int i = 1; i < d; i++) temp[rr[i]]++;
  for (int i = d; i <= n; i++) {
    temp[rr[i]]++;
    int pp = 0;
    for (int j = 0; j < m; j++)
      if (!temp[j]) pp += (1 << j);
    check[pp] = 1;
    temp[rr[i - d + 1]]--;
  }
  int ans = 100;
  for (int i = (1 << m) - 1; i >= 0; i--)
    if (check[i]) {
      for (int j = 0; j < m; j++)
        if (i & (1 << j)) check[i - (1 << j)] = 1;
    } else
      ans = min(ans, (int)popcount(i));
  printf("%d\n", ans);
  return 0;
}
