#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int(i) = 0; (i) < (((int)((t).size()))); ++(i)) s << t[i] << " ";
  return s;
}
int where[2000007], ile[22], m;
bool zle[2000007];
void ustaw(int ma) {
  if (zle[ma]++) return;
  for (int(i) = 0; (i) < (m); ++(i))
    if ((1 << i) & ma) ustaw(ma ^ (1 << i));
}
int main() {
  int(n), (mm), (d);
  scanf("%d %d %d", &(n), &(mm), &(d));
  m = mm;
  for (int(i) = 0; (i) < (m); ++(i)) {
    int(testow);
    scanf("%d", &(testow));
    while (testow--) {
      int(x);
      scanf("%d", &(x));
      where[x] = i;
    }
  }
  int mask = 0;
  for (int(p) = (1); (p) <= (d); ++p) {
    mask |= 1 << where[p];
    ile[where[p]]++;
  }
  ustaw((1 << m) - 1 - mask);
  for (int(x) = (1); (x) <= (n - d); ++x) {
    if (--ile[where[x]] == 0) mask &= ~(1 << where[x]);
    if (ile[where[x + d]]++ == 0) mask |= (1 << where[x + d]);
    ustaw((1 << m) - 1 - mask);
  }
  int ans = 1001001001;
  for (int(res) = 0; (res) < (1 << m); ++(res))
    if (!zle[res]) (ans) = min((ans), (__builtin_popcount(res)));
  ;
  pisz(ans);
}
