#C8104. Dinner Party Dilemma

    ID: 52050 Type: Default 1000ms 256MiB

Dinner Party Dilemma

Dinner Party Dilemma

You are given a set of available ingredients and a list of candidate dishes. Each dish requires a certain number of ingredients, and each ingredient can be used at most once. Your task is to determine the maximum number of dishes that can be prepared such that no ingredient is reused.

The input provides two integers: \(n\), the number of available ingredients, and \(m\), the number of dishes. Each dish is described by an integer \(k\) (the number of required ingredients) followed by \(k\) ingredient names. A dish can only be prepared if all its required ingredients are available in the provided ingredient list.

Note: An ingredient can appear in at most one dish in your final selection. In other words, if two dishes share a common ingredient, they cannot both be prepared.

Your solution should read from standard input (stdin) and output the answer to standard output (stdout).

inputFormat

The first line contains two integers \(n\) and \(m\) separated by a space, where \(n\) is the number of available ingredients and \(m\) is the number of dishes.

The next \(n\) lines each contain a single ingredient name.

The following \(m\) lines each describe a dish. Each such line starts with an integer \(k\), the number of required ingredients for that dish, followed by \(k\) space-separated ingredient names.

Example:

5 3

tomato cheese lettuce bread chicken

2 tomato cheese 2 bread cheese 3 chicken lettuce tomato

</p>

outputFormat

Output a single integer: the maximum number of dishes that can be made without using any ingredient more than once.

## sample
5 3
tomato
cheese
lettuce
bread
chicken
2 tomato cheese
2 bread cheese
3 chicken lettuce tomato
2