#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const double EPS = 10e-9;
const int MAXN = 100000;
const int MAXM = 20;
int t[MAXN];
int cnt[MAXM];
bool badSets[1 << MAXM];
inline void add(int s, int &bSets) {
  if (!cnt[s]) bSets ^= 1 << s;
  ++cnt[s];
}
inline void del(int s, int &bSets) {
  --cnt[s];
  if (!cnt[s]) bSets |= 1 << s;
}
inline void addBadSets(int bSets) { badSets[bSets] = 1; }
void rob() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);
  int si, a;
  for (typeof(0) i = (0); i < (m); ++i) {
    scanf("%d", &si);
    for (typeof(0) j = (0); j < (si); ++j) {
      scanf("%d", &a);
      t[a - 1] = i;
    }
  }
  int bSets = (1 << m) - 1;
  for (typeof(0) i = (0); i < (d); ++i) add(t[i], bSets);
  addBadSets(bSets);
  for (typeof(d) i = (d); i < (n); ++i) {
    add(t[i], bSets);
    del(t[i - d], bSets);
    addBadSets(bSets);
  }
  int res = INF;
  for (typeof((1 << m) - 1) i = ((1 << m) - 1); i >= (0); --i) {
    if (badSets[i])
      for (typeof(0) j = (0); j < (m); ++j) addBadSets(i ^ (1 << j));
    else
      res = min(res, __builtin_popcount(i));
  }
  printf("%d\n", res);
}
int main() {
  int test = 1;
  while (test--) rob();
  return 0;
}
