# Maximum flow and matchings

# 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`

, followed by different numbers _{i}`A`

, _{1}`A`

, ..., _{2}`A`

- the kinds of coffee that likes _{Xi}**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`

, followed by different numbers _{i}`B`

, _{1}`B`

, ..., _{2}`B`

- the kinds of cakes that likes _{Yi}**i**-th student.

#### Output

Print the maximum number of students that can be served in cafe.

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

2