#include <bits/stdc++.h>
using namespace std;
const int MOD = 95542721;
const int N = 100000;
bool vis[(1 << 20) + 1];
int n, m, d, idx[N + 1];
void mark(int msk) {
  if (vis[msk]) return;
  vis[msk] = 1;
  for (int i = 0; i < m; ++i)
    if ((msk & (1 << i)) > 0) {
      int newMsk = msk ^ (1 << i);
      mark(newMsk);
    }
}
int freq[21];
int main() {
  cin >> n >> m >> d;
  for (int a, i = 0; i < m; ++i) {
    scanf("%d", &a);
    for (int f, j = 0; j < a; ++j) {
      scanf("%d", &f);
      idx[f] = i;
    }
  }
  for (int i = 0; i < m; ++i) freq[i] = 0;
  int cnt = 1;
  for (int i = 1; i + d - 1 <= n; ++i) {
    while (cnt < i + d) {
      freq[idx[cnt]]++;
      cnt++;
    }
    int mrk = 0;
    for (int i = 0; i < m; ++i)
      if (freq[i] == 0) mrk ^= (1 << i);
    mark(mrk);
    freq[idx[i]]--;
  }
  int ans = m;
  for (int i = 0; i < (1 << m); ++i)
    if (!vis[i]) ans = min(ans, __builtin_popcount(i));
  cout << ans << endl;
  return 0;
}
