#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = 1e9 + 7;
const int logN = 16 + 1;
const int inf = 1e9 + 0;
const int N = 2e6 + 5;
int x, cnt[N], dp[N], n, m, d, l, w[N];
int main() {
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &l);
    for (int j = 1; j <= l; j++) {
      scanf("%d", &x);
      w[x] = i;
    }
  }
  for (int i = 1; i <= d - 1; i++) cnt[w[i]]++;
  for (int i = 1; i <= n - d + 1; i++) {
    cnt[w[i + d - 1]]++;
    int mask = 0;
    for (int j = 1; j <= m; j++)
      if (!cnt[j]) mask += (1 << j - 1);
    cnt[w[i]]--;
    dp[mask] = 1;
  }
  for (int i = 0; i <= m - 1; i++)
    for (int j = (1 << m) - 1; j >= 0; j--)
      if (j & (1 << i) && dp[j]) dp[j - (1 << i)] = true;
  int ans = inf;
  for (int j = 0; j <= (1 << m) - 1; j++) {
    if (!dp[j]) {
      ans = min(ans, __builtin_popcount(j));
    }
  }
  cout << ans << '\n';
}
