Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the stalls in the new barn are different. For the first week, Farmer John randomly assigned cows to stalls, but it quickly became clear that any given cow was only willing to produce milk in certain stalls. For the last week, Farmer John has been collecting data on which cows are willing to produce milk in which stalls. A stall may be only assigned to one cow, and, of course, a cow may be only assigned to one stall.
Given the preferences of the cows, compute the maximum number of milk-producing assignments of cows to stalls that is possible.
Given the preferences of the cows, compute the maximum number of milk-producing assignments of cows to stalls that is possible.
Input
The input includes several cases. For each case, the first line contains two integers, N (0 <= N <= 200) and M (0 <= M <= 200). N is the number of cows that Farmer John has and M is the number of stalls in the new barn. Each of the following N lines corresponds to a single cow. The first integer (Si) on the line is the number of stalls that the cow is willing to produce milk in (0 <= Si <= M). The subsequent Si integers on that line are the stalls in which that cow is willing to produce milk. The stall numbers will be integers in the range (1..M), and no stall will be listed twice for a given cow.
Output
For each case, output a single line with a single integer, the maximum number of milk-producing stall assignments that can be made.
Sample Input
5 5 2 2 5 3 2 3 4 2 1 5 3 1 2 5 1 2
Sample Output
4
说明
农民约翰刚在上星期,完成与所有最新挤奶技术完成了他新的粮仓。 不幸的是,由于工程的问题在新谷仓里所有公众街市摊档是不同的。 在第一的周农民约翰随机分配的母牛给档,但它很快就成为清楚的任何给定的牛只是愿意产奶在某些档。 最后一周为农民约翰一直收集的数据的母牛都愿意产奶中的摊位。 一档可能将只分配给母牛,和当然,一头牛可能只分配到一个摊位。
给母牛的偏好,计算最大的牛奶生产的母牛是可能的档工作分配。
输入
输入包含几个例。 每种情况下的第一行包含两个的整数 N (0 < = N < = 200) 和 M (0 < = M < = 200)。 N 是农民有的牛的数量和 M 是新的谷仓中的次数。 每个以下 N 行对应于一个单一的牛。 行上的第一个整数 (Si) 是摊档,牛是愿意产奶中的数量 (0 < = 硅 < = M)。 该行上的整数,在其中,牛的摊档的后续硅是愿意产奶。 摊位号码会 (1..M),范围内的整数,没有摊档将列出两次为给定的母牛。输出
为每种情况下输出一行用一个单一的整数可以使牛奶生产的摊位分配的最大数目。示例输入
5 5 2 2 5 3 2 3 4 2 1 5 3 1 2 5 1 2示例输出
4