#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
map<string, int> Id;
int Par[100100], Cost[100100];
int parent(int u) {
  if (u == Par[u]) return u;
  return Par[u] = parent(Par[u]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    string u;
    cin >> u;
    Id[u] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> Cost[i];
    Par[i] = i;
  }
  for (int i = 1; i <= k; i++) {
    int sz;
    cin >> sz;
    int head;
    cin >> head;
    sz--;
    while (sz--) {
      int node;
      cin >> node;
      Cost[head] = min(Cost[head], Cost[node]);
      Par[node] = head;
    }
  }
  long long res = 0;
  for (int i = 1; i <= m; i++) {
    string u;
    cin >> u;
    res += Cost[parent(Id[u])];
  }
  cout << res << endl;
  return 0;
}
