#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
template <class T>
void dbs(string str, T t) {
  cout << str << " : " << t << endl;
}
template <class T, class... second>
void dbs(string str, T t, second... s) {
  int idx = str.find(',');
  cout << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
template <class second, class T>
ostream& operator<<(ostream& os, const pair<second, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class second, class T>
ostream& operator<<(ostream& os, const map<second, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
void prc(T a, T b) {
  cout << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cout << ", ";
    cout << *i;
  }
  cout << "]";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, d;
  cin >> n >> m >> d;
  vector<int> a(n);
  for (auto i = (0); i <= (m - 1); ++i) {
    int s;
    cin >> s;
    for (auto j = (0); j <= (s - 1); ++j) {
      int x;
      cin >> x;
      --x;
      a[x] = i;
    }
  }
  vector<int> f(m);
  for (auto i = (0); i <= (d - 1); ++i) f[a[i]]++;
  vector<int> chi(1 << m);
  for (auto i = (0); i <= (n - 1); ++i) {
    int j = i + d - 1;
    if (j >= n) break;
    if (i) {
      f[a[j]]++;
      f[a[i - 1]]--;
    }
    int mask = (1 << m) - 1;
    for (auto k = (0); k <= (m - 1); ++k)
      if (f[k]) mask ^= (1 << k);
    chi[mask] = 1;
  }
  for (auto i = ((1 << m) - 1); i >= (0); --i) {
    for (auto j = (0); j <= (m - 1); ++j) chi[i] |= chi[i | (1 << j)];
  }
  int ans = m;
  for (auto i = (0); i <= ((1 << m) - 1); ++i)
    if (!chi[i]) ans = min(ans, __builtin_popcount(i));
  cout << ans;
  return 0;
}
