#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int n, m, d;
int c[100011];
int bad[1 << 20];
int cnt[100011];
void solve() {
  gn(n);
  gn(m);
  gn(d);
  for (int i = 0; i < m; i++) {
    int s;
    gn(s);
    while (s--) {
      int u;
      gn(u);
      c[u] = i;
    }
  }
  int now = 0;
  int all = (1 << m) - 1;
  for (int i = 1; i <= n; i++) {
    cnt[c[i]]++;
    now |= (1 << c[i]);
    if (i >= d) {
      bad[all ^ now] = 1;
      if (--cnt[c[i - d + 1]] == 0) now ^= (1 << c[i - d + 1]);
    }
  }
  for (int i = all; i >= 0; i--)
    if (bad[i]) {
      for (int j = 0; j < m; j++)
        if ((((i) >> (j)) & 1)) bad[i ^ (1 << j)] = 1;
    }
  int ans = m;
  for (int i = 0; i <= all; i++)
    if (bad[i] == 0) smin(ans, (__builtin_popcount(i)));
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
