Dining

No attempts yetTime limit1sMemory limit128 MB

Problem

Cows are finicky eaters: each cow will eat only certain foods and drink only certain drinks.

Farmer John has cooked meals for his cows but forgot to check the menu against their preferences. He may not be able to satisfy everyone, so he wants to serve a complete meal — one food and one drink — to as many cows as possible.

Farmer John has prepared $F$ types of food and $D$ types of drink ($1 \le F, D \le 100$). Each of the $N$ cows ($1 \le N \le 100$) has decided which foods she is willing to eat and which drinks she is willing to drink. Assign one food type and one drink type to each cow so as to maximize the number of cows that receive both a food and a drink they like.

Each serving of food and each serving of drink can be given to only one cow (for example, once food type 2 is assigned to some cow, no other cow may be assigned food type 2). Each cow may be assigned at most one food and at most one drink.

Input

  • Line 1: three space-separated integers $N$, $F$, and $D$.
  • Lines 2 to $N+1$: line $i+1$ describes cow $i$. It begins with two integers $F_i$ and $D_i$ — the number of foods cow $i$ likes and the number of drinks cow $i$ likes. The next $F_i$ integers are the foods cow $i$ will eat, and the following $D_i$ integers are the drinks cow $i$ will drink.

Output

  • A single integer: the maximum number of cows that can each be served both a food and a drink they are willing to consume.