#include <bits/stdc++.h>
using namespace std;
inline void R(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0'; ch = getchar())
    ;
  for (; ch >= '0'; ch = getchar()) x = x * 10 + ch - '0';
}
const int N = 100005;
int n, m, k, d, bel[N], cnt[N][22];
bool f[1048577];
int main() {
  R(n);
  R(m);
  R(d);
  int x;
  for (int i = 0; i < m; ++i) {
    R(k);
    for (int j = 1; j <= k; ++j) {
      R(x);
      bel[x] = i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < m; ++j) cnt[i][j] = cnt[i - 1][j] + (bel[i] == j);
  }
  int ans = 100, c;
  for (int i = d; i <= n; ++i) {
    c = 0;
    for (int j = 0; j < m; ++j)
      if (!(cnt[i][j] - cnt[i - d][j])) c |= 1 << j;
    f[c] = 1;
  }
  for (int i = (1 << m) - 1; i; --i) {
    if (f[i]) {
      for (int j = 0; j < m; ++j)
        if ((i >> j) & 1) f[i ^ (1 << j)] = 1;
    } else
      ans = min(ans, __builtin_popcount(i));
  }
  printf("%d\n", ans);
  return 0;
}
