#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  string words[n];
  map<string, int> words_to_groups;
  for (int i = 0; i < n; i++) {
    cin >> words[i];
  }
  long long int costs[n];
  for (int i = 0; i < n; i++) {
    cin >> costs[i];
  }
  int word_to_group[k];
  int group_min[k];
  for (int i = 0; i < k; i++) {
    int x, index;
    cin >> x;
    cin >> index;
    index--;
    words_to_groups[words[index]] = i;
    group_min[i] = costs[index];
    for (int j = 1; j < x; j++) {
      cin >> index;
      index--;
      words_to_groups[words[index]] = i;
      if (group_min[i] > costs[index]) {
        group_min[i] = costs[index];
      }
    }
  }
  long long int total = 0;
  for (int i = 0; i < m; i++) {
    string word;
    cin >> word;
    total += group_min[words_to_groups[word]];
  }
  cout << total;
}
