#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;
int *buildRMQ(int *a, int n) {
  int logn = 1;
  for (int k = 1; k < n; k *= 2) ++logn;
  int *r = new int[n * logn];
  int *b = r;
  copy(a, a + n, b);
  for (int k = 1; k < n; k *= 2) {
    copy(b, b + n, b + n);
    b += n;
    for (int i = 0; i < (int)n - k; i++) b[i] |= b[i + k];
  }
  return r;
}
inline int minimum(int x, int y, int *rmq, int n) {
  int z = y - x, k;
  if (z <= 0) return rmq[x];
  __asm("bsrl %1, %0\n\t" : "=r"(k) : "r"(z) :);
  return rmq[x + n * k] | rmq[y + n * k - (1 << k) + 1];
}
int n, m, d;
int a[100010], ng[(1 << 20) - 1];
int main() {
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 0; i < (int)m; i++) {
    int k, t;
    scanf("%d", &k);
    for (int j = 0; j < (int)k; j++) {
      scanf("%d", &t);
      a[t] |= 1 << i;
    }
  }
  int ans = m;
  int *rmq = buildRMQ(a, n + 1);
  for (int i = d; i <= n; i++) {
    int x = minimum(i - d + 1, i, rmq, n + 1);
    ng[(1 << m) - 1 - x] = 1;
  }
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (!ng[i])
      ans = min(ans, __builtin_popcount(i));
    else
      for (int j = 0; j < (int)m; j++)
        if (i & 1 << j) ng[i ^ 1 << j] = 1;
  }
  cout << ans << endl;
  return 0;
}
