#include <bits/stdc++.h>
using namespace std;
void desperate_optimization(int precision) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
const int N = 2e6;
int grup[N + 5];
int occ[N + 5];
int dp[N + 5];
void hora(int tc) {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      grup[x] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    occ[grup[i]]++;
    if (i >= d) {
      int nyala = 0;
      for (int j = 0; j < m; j++) {
        if (occ[j] == 0) nyala |= (1 << j);
      }
      dp[nyala] = 1;
      occ[grup[i - d + 1]]--;
    }
  }
  for (int i = (1 << m) - 1; i >= 0; i--) {
    for (int j = 0; j < m; j++) dp[i] |= dp[i | (1 << j)];
  }
  int res = 50;
  for (int i = 1; i < (1 << m); i++)
    if (dp[i] == 0) res = min(res, __builtin_popcount(i));
  printf("%d\n", res);
}
int main() {
  desperate_optimization(10);
  int ntc = 1;
  for (int tc = 1; tc <= ntc; tc++) hora(tc);
  return 0;
}
