열혈강호 123456789101112131415161718192021222324252627282930313233343536373839404142434445#include <bits/stdc++.h>#define MAX_N 1001#define ll long long#define all(a) begin(a), end(a)using namespace std;ll n, m;ll match[MAX_N], seen[MAX_N];vector<int> job[MAX_N];ll dfs(ll u, ll s) { for(auto& v : job[u]) { if(seen[v] == s) continue; seen[v] = s; if(match[v] == -1 or dfs(match[v], s)) { match[v] = u; return 1; } } return 0;}ll solve() { ll res = 0; for(ll i = 1; i <= n; i++) { if(dfs(i,i)) res++; } return res;}int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; memset(match, -1, sizeof(match)); for(ll i = 1, w, j; i <= n; i++) { cin>>w; while(w--) { cin>>j; job[i].push_back(j); } } cout<<solve(); return 0;}