Mahmoud wants to send a message to his friend Ehab. Their language consists of _n_ words numbered from 1 to _n_. Some words have the same meaning so there are _k_ groups of words such that all the words in some group have the same meaning.
Mahmoud knows that the _i_\-th word can be sent with cost _a__i_. For each word in his message, Mahmoud can either replace it with another word of the same meaning or leave it as it is. Can you help Mahmoud determine the minimum cost of sending the message?
The cost of sending the message is the sum of the costs of sending every word in it.
## Input
The first line of input contains integers _n_, _k_ and _m_ (1 ≤ _k_ ≤ _n_ ≤ 105, 1 ≤ _m_ ≤ 105) — the number of words in their language, the number of groups of words, and the number of words in Mahmoud's message respectively.
The second line contains _n_ strings consisting of lowercase English letters of length not exceeding 20 which represent the words. It's guaranteed that the words are **distinct**.
The third line contains _n_ integers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ 109) where _a__i_ is the cost of sending the _i_\-th word.
The next _k_ lines describe the groups of words of same meaning. The next _k_ lines each start with an integer _x_ (1 ≤ _x_ ≤ _n_) which means that there are _x_ words in this group, followed by _x_ integers which represent the indices of words in this group. It's guaranteed that each word appears in exactly one group.
The next line contains _m_ space-separated words which represent Mahmoud's message. Each of these words appears in the list of language's words.
## Output
The only line should contain the minimum cost to send the message after replacing some words (maybe none) with some words of the same meaning.
[samples]
## Note
In the first sample, Mahmoud should replace the word "_second_" with the word "_loser_" because it has less cost so the cost will be 100+1+5+1=107.
In the second sample, Mahmoud shouldn't do any replacement so the cost will be 100+1+5+10=116.
Mahmoud 想要给他的朋友 Ehab 发送一条消息。他们的语言由 #cf_span[n] 个单词组成,编号从 #cf_span[1] 到 #cf_span[n]。有些单词意思相同,因此共有 #cf_span[k] 组单词,每组中的所有单词意思相同。
Mahmoud 知道,第 #cf_span[i] 个单词的发送代价为 #cf_span[ai]。对于消息中的每个单词,Mahmoud 可以选择用同义词替换它,也可以保留原样。你能帮助 Mahmoud 确定发送消息的最小代价吗?
发送消息的代价是发送其中每个单词的代价之和。
输入的第一行包含整数 #cf_span[n], #cf_span[k] 和 #cf_span[m] #cf_span[(1 ≤ k ≤ n ≤ 105, 1 ≤ m ≤ 105)] —— 分别表示语言中单词的数量、单词组的数量以及 Mahmoud 消息中单词的数量。
第二行包含 #cf_span[n] 个由小写英文字母组成的字符串,长度不超过 20,表示这些单词。保证这些单词互不相同。
第三行包含 #cf_span[n] 个整数 #cf_span[a1], #cf_span[a2], #cf_span[...], #cf_span[an] #cf_span[(1 ≤ ai ≤ 109)],其中 #cf_span[ai] 表示发送第 #cf_span[i] 个单词的代价。
接下来的 #cf_span[k] 行描述了意思相同的单词组。接下来的 #cf_span[k] 行中,每行以一个整数 #cf_span[x] #cf_span[(1 ≤ x ≤ n)] 开头,表示该组中有 #cf_span[x] 个单词,随后是 #cf_span[x] 个整数,表示该组中单词的索引。保证每个单词恰好属于一个组。
下一行包含 #cf_span[m] 个用空格分隔的单词,表示 Mahmoud 的消息。这些单词均出现在语言的单词列表中。
仅输出一行,包含在替换部分(可能不替换)单词为同义词后,发送消息的最小代价。
在第一个样例中,Mahmoud 应将单词 "_second_" 替换为 "_loser_",因为它的代价更小,因此总代价为 100+1+5+1=107。
在第二个样例中,Mahmoud 不应进行任何替换,因此代价为 100+1+5+10=116。
## Input
输入的第一行包含整数 #cf_span[n], #cf_span[k] 和 #cf_span[m] #cf_span[(1 ≤ k ≤ n ≤ 105, 1 ≤ m ≤ 105)] —— 分别表示语言中单词的数量、单词组的数量以及 Mahmoud 消息中单词的数量。第二行包含 #cf_span[n] 个由小写英文字母组成的字符串,长度不超过 20,表示这些单词。保证这些单词互不相同。第三行包含 #cf_span[n] 个整数 #cf_span[a1], #cf_span[a2], #cf_span[...], #cf_span[an] #cf_span[(1 ≤ ai ≤ 109)],其中 #cf_span[ai] 表示发送第 #cf_span[i] 个单词的代价。接下来的 #cf_span[k] 行描述了意思相同的单词组。接下来的 #cf_span[k] 行中,每行以一个整数 #cf_span[x] #cf_span[(1 ≤ x ≤ n)] 开头,表示该组中有 #cf_span[x] 个单词,随后是 #cf_span[x] 个整数,表示该组中单词的索引。保证每个单词恰好属于一个组。下一行包含 #cf_span[m] 个用空格分隔的单词,表示 Mahmoud 的消息。这些单词均出现在语言的单词列表中。
## Output
仅输出一行,包含在替换部分(可能不替换)单词为同义词后,发送消息的最小代价。
[samples]
## Note
在第一个样例中,Mahmoud 应将单词 "_second_" 替换为 "_loser_",因为它的代价更小,因此总代价为 100+1+5+1=107。在第二个样例中,Mahmoud 不应进行任何替换,因此代价为 100+1+5+10=116。
**Definitions**
Let $ n, k, m \in \mathbb{Z}^+ $ denote:
- $ n $: number of distinct words in the language,
- $ k $: number of synonym groups,
- $ m $: number of words in the message.
Let $ W = (w_1, w_2, \dots, w_n) $ be the sequence of distinct words (strings).
Let $ C = (c_1, c_2, \dots, c_n) $ be the sequence of costs, where $ c_i \in \mathbb{Z}^+ $ is the cost of word $ w_i $.
Let $ G = \{G_1, G_2, \dots, G_k\} $ be a partition of $ \{1, 2, \dots, n\} $ into $ k $ disjoint groups, where each group $ G_j $ contains indices of words that are synonyms (i.e., have the same meaning).
Let $ M = (m_1, m_2, \dots, m_m) $ be the sequence of words in Mahmoud’s message, where each $ m_i \in W $.
For each word $ m_i $ in the message, let $ \text{idx}(m_i) \in \{1, \dots, n\} $ be the index of $ m_i $ in $ W $.
For each group $ G_j $, define $ \min_c(G_j) = \min \{ c_\ell \mid \ell \in G_j \} $: the minimum cost among all words in group $ G_j $.
**Constraints**
1. $ 1 \le k \le n \le 10^5 $
2. $ 1 \le m \le 10^5 $
3. $ 1 \le c_i \le 10^9 $
4. Each word in $ W $ appears in exactly one group $ G_j $.
5. Each word in $ M $ is in $ W $.
**Objective**
Compute the minimum total cost to send the message:
$$
\sum_{i=1}^{m} \min_c(G_{j(i)})
$$
where $ j(i) $ is the unique group index such that $ \text{idx}(m_i) \in G_{j(i)} $.