1045 - Task Arrangement II

Time Limit: 1s Memory Limit: 64MB

Submissions: 87 Solved: 29
There are N tasks and M resources, each task is asked to use some resources and each resource can only be used by at most one task. You are asked to find the best arrangement to maximum the total number of the compatible tasks.
There are multi test cases. Each case contains a number of lines. The first line is N and M, 1 <= N, M <= 50. In the following N lines, each task contains one line with many integers separated by exactly one space, which specify the required resources. The index of the resources starts from 0.
For each test case, output one line containing the maximum number of the compatible tasks.
Sample Input
5 5
0 3 1
1 4
2 1
3 2
3 3
1 0
0 2
1 2
Sample Output
Du Peng