Dead Or Alive
#描述#
Only several people survive after Doomsday, and a small number of cities have not been destroyed. Xenocide wants to arrange these people to live on the available cities.
Now all the people follow xenocide to pass the cities.
<br>
<br>
But there are some restrictions on the cities. Some people will die when pass some cities and every city has a population limitation. If people can’t find a city to live after passing all cities they will be dead! So the order of passing the cities is important.
#格式#
##输入格式##
The first line an integer T (1<=T<=100) which means the number of test cases.
Each case starts with two integers n and m, which means the number of people and the number of cities. (1<= n <= 31, 1 <= m <= 15)
Second line has m integers, the ith integer Ci means ith city’s population limitation. The cities are ordered from 0 to m-1.
Then n lines follow. Each line starts with an integer k which means the number of cities this people will die when passing it. Then k integers follow.
##输出格式##
The maximum number of people can survive!
#样例1#
##样例输入1##
2
3 3
3 3 2
1 1
0
2 1 2
3 3
2 1 2
2 0 1
2 0 2
1 2
##样例输出1##
3
2
#限制#
1000ms
32768KB
#提示#
#来源#