시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 256 MB 0 0 0 0.000%

문제

There are $n$ boxes (numbered $1$ through $n$), $m$ keys (numbered $1$ through $m$), and $d$ shops (numbered $1$ through $d$). The key $i$ can be used to open one of the boxes $a_{i,1}, \ldots, a_{i,k_i}$. However, once a key is used to open a box, it disappears. Thus, a key can't be used to open multiple boxes. The key $i$ is sold at the shop $s_i$, and its price is $c_i$ dollars. Akiba wants to buy some keys and open all the boxes. (He can't buy the same key multiple times.)

Kitamasa wants to prevent Akiba from doing this. In order to do it, he can change the prices of some keys before Akiba decides which keys to buy. If he pays $b_j$ dollars, he can increase the prices of all keys sold at the shop $j$ by one dollar. For each shop, he can repeat this any non-negative integer number of times: for example, if he pays $2 b_j$ dollars, he can increase the prices of all keys sold at the shop $j$ by two dollars. However, for example when $b_j = 2$, he can't pay $1$ dollar and change the prices by $0.5$ dollars.

Akiba's objective is to minimize the value (Akiba's payment) $-$ (Kitamasa's payment), and Kitamasa's objective is to maximize it. Compute this value when the two players play optimally. If the answer can be infinitely large, print $-1$. It is guaranteed that if Kitamasa does nothing, Akiba can open all boxes.

입력

The first line of input contains three integers $n$, $m$, and $d$ ($1 \le m \le 1000$, $n \le 100$, $1 \le n, d \le m$).

Then $m$ lines follow, each describing one key. Each line starts with three integers: $c_i$, the price of the key, $s_i$, the number of the shop where the key is sold, and $k_i$, the number of boxes this key can open. Then $k_i$ integers follow: the numbers of these boxes ($1 \le c_i \le 1000$, $1 \le s_i \le d$, $1 \le k_i \le \min (10, n)$, $1 \le a_{i,j} \le n$, and if $j \ne k$, $a_{i,j} \ne a_{i,k}$).

Then $d$ lines follow, each containing one integer $b_i$ ($1 \le b_i \le 1000$).

출력

Print one integer: the answer to the problem.

예제 입력 1

3 4 1
2 1 2 1 2
2 1 2 2 3
2 1 2 3 1
3 1 3 1 2 3
5

예제 출력 1

6

예제 입력 2

3 4 1
2 1 2 1 2
2 1 2 2 3
2 1 2 3 1
3 1 3 1 2 3
2

예제 출력 2

-1

예제 입력 3

2 3 2
3 1 2 1 2
4 1 1 2
5 2 2 1 2
1
2

예제 출력 3

8