#include <bits/stdc++.h>
using namespace std;
int N, M, D, cnt[21];
bool mark[21][100005], imp[(1 << 20)];
int main() {
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &D);
  for (int i = 0; i < M; i++) {
    int s, a;
    scanf("%d", &s);
    for (int j = 0; j < s; j++) {
      scanf("%d", &a);
      mark[i][a] = true;
    }
  }
  for (int i = 1; i <= N; i++) {
    int msk = 0;
    for (int j = 0; j < M; j++) {
      if (mark[j][i]) cnt[j]++;
      if (i > D && mark[j][i - D]) cnt[j]--;
      if (i >= D && !cnt[j]) msk |= (1 << j);
    }
    imp[msk] = true;
  }
  int ans = M, mx = (1 << M);
  for (int i = mx - 1; i > 0; i--)
    if (imp[i]) {
      for (int j = 0; j < M; j++)
        if (i & (1 << j)) imp[i ^ (1 << j)] = true;
    }
  for (int i = 1; i < (1 << M); i++)
    if (!imp[i]) ans = min(ans, __builtin_popcount(i));
  printf("%d\n", ans);
}
