#P3410. 拍照

拍照

Description

Xiao B has NN subordinates. Now Xiao B plans to bring some subordinates to have photos taken.

There are MM people; each person is willing to pay Xiao B some money to take a photo with some of the NN subordinates. If that set of subordinates is not fully brought, the photo cannot be taken, and Xiao B will not receive the payment.

Note: Bringing subordinates is not free! For each subordinate who is brought, Xiao B needs to pay a fee to ensure cooperation during the photo.

Input Format

The first line contains 22 positive integers MM and N (1M,N100)N\ (1\leq M, N\le 100). The next MM lines each describe one requester’s data. The first number is the fee he agrees to pay for that photo; then follow the IDs of the required subordinates, terminated by a 00 as the end marker for the line. The last line contains NN numbers, the cost to bring each subordinate.

Output Format

A single number, the maximum profit. Xiao B may choose to bring nobody.

2 3
10 1 2 0
25 2 3 0
5 6 7
17

Hint

For 10%10\% of the testdata, each person requires all NN subordinates.

For 30%30\% of the testdata, N,M15N, M\le 15.

For another 10%10\% of the testdata, the answer is 00.

For 50%50\% of the testdata, N,M40N, M\le 40.

For another 10%10\% of the testdata, each person requires exactly one subordinate.

For 100%100\% of the testdata, 1N,M1001\leq N, M\le100, and fees are integers in [1,5×108][1, 5\times 10^8].

Translated by ChatGPT 5