Cafe
Today n students came to the New University Cafe. Each of them wants to drink a cup of coffee and to eat one cake (none of them does not agree only on coffee or just a cake - in this case the student leaves). The café serves m kinds of coffees and k kinds of cakes. For each type of coffee and pastry it is known how many cups or servings of this type is available.
In addition, each student has his own taste preferences. It is known for each student what kinds of coffee and cakes he loves. None of the students do not agree to eat or drink something other that he does not like.
The owner of the cafe is thinking: what is the maximum number of students can he serve? And can you find this number?
Input
First line contains integers n, m, k (1 ≤ n, m, k ≤ 500).
Second line contains m integers C[1]
, C[2]
, ..., C[m]
(1 ≤ C[i]
≤ 500) - the number of available cups of coffee for each type.
Third line contains k integers P[1]
, P[2]
, ..., P[k]
(1 ≤ P[i]
≤ 500) - the number of available cakes for each type.
Next n lines give the information what kind of coffee likes each student. i-th line (1 ≤ i ≤ n) contains number X[i]
, followed by different numbers A[1]
, A[2]
, ..., A[Xi]
- the kinds of coffee that likes i-th student.
Next n lines give the information what kind of cakes likes each student. i-th line (1 ≤ i ≤ n) contains number Y[i]
, followed by different numbers B[1]
, B[2]
, ..., B[Yi]
- the kinds of cakes that likes i-th student.
Output
Print the maximum number of students that can be served in cafe.