1 #include <iostream>
2 #include <cstdio>
3 #include <cstdlib>
4 #include <cstring>
5 #include <algorithm>
6 inline void read(int &x){x = 0;char ch = getchar();char c = ch;while(ch > ‘9‘ || ch < ‘0‘)c = ch, ch = getchar();while(ch <= ‘9‘ && ch >= ‘0‘)x = x * 10 + ch - ‘0‘, ch = getchar();if(c == ‘-‘)x = -x;}
7 const int MAXN = 2000 + 10;
8
9 int n;
10 int g[MAXN][MAXN],by[MAXN],lk[MAXN];
11 int ans;
12
13 int find(int v)
14 {
15 for(register int i = 1;i <= n;++ i)
16 {
17 if(!by[i] && (!g[v][i]))
18 {
19 by[i] = 1;
20 if((!lk[i]) || find(lk[i]))
21 {
22 lk[i] = v;
23 return 1;
24 }
25 }
26 }
27 return 0;
28 }
29
30 int main()
31 {
32 read(n);
33 register int m, tmp;
34 for(register int i = 1;i <= n;++ i)
35 {
36 read(m);
37 for(register int j = 1;j <= m;++ j)
38 {
39 read(tmp);
40 g[i][tmp] = 1;
41 }
42 }
43 for(register int i = 1;i <= n;++ i)
44 {
45 memset(by, 0, sizeof(by));
46 if(find(i))ans ++;
47 }
48 printf("%d", ans);
49 return 0;
50 }