#include <bits/stdc++.h>
using namespace std;
int n, m, d, Set[100005], cnt[100005], COST[2000005], OK[2000005],
    ans = 1e9 + 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> d;
  for (int i = 0; i <= n; i++) Set[i] = m;
  int u, Val;
  for (int i = 1; i <= m; i++) {
    cin >> u;
    while (u--) {
      cin >> Val;
      Set[Val] = i - 1;
    }
  }
  for (int i = 1; i < d; i++) cnt[Set[i]]++;
  for (int i = d; i <= n; i++) {
    int cur = 0;
    cnt[Set[i]]++;
    cnt[Set[i - d]]--;
    for (int i = 0; i < m; i++)
      if (cnt[i] == 0) cur |= (1 << i);
    OK[cur] = 1;
  }
  for (int i = ((1 << m) - 1); i >= 0; i--) {
    if (OK[i] == 0) continue;
    for (int j = 0; j < m; j++)
      if (((i >> j) & 1)) OK[i - (1 << j)] = 1;
  }
  for (int i = 1; i < (1 << m); i++) {
    COST[i] = COST[i - (i & (-i))] + 1;
    if (OK[i]) continue;
    ans = min(ans, COST[i]);
  }
  cout << ans;
}
