#include <bits/stdc++.h>
using namespace std;
int pr[110000];
int sz[110000];
int find_set(int v) {
  if (v == pr[v])
    return v;
  else
    return find_set(pr[v]);
}
void union_sets(int x, int y) {
  x = find_set(x);
  y = find_set(y);
  if (x == y) return;
  if (sz[x] > sz[y]) swap(x, y);
  pr[y] = x;
}
int main() {
  int x, i, n, j, z, pz, k, m;
  long long ans;
  string s;
  map<string, int> mapa;
  cin >> n >> k >> m;
  for (i = 1; i <= n; i++) {
    cin >> s;
    mapa[s] = i;
  }
  for (i = 1; i <= n; i++) {
    pr[i] = i;
    cin >> x;
    sz[i] = x;
  }
  for (i = 1; i <= k; i++) {
    cin >> x;
    cin >> pz;
    for (j = 2; j <= x; j++) {
      cin >> z;
      union_sets(pz, z);
      pz = z;
    }
  }
  ans = 0;
  for (i = 1; i <= m; i++) {
    cin >> s;
    x = mapa[s];
    x = find_set(x);
    ans += sz[x];
  }
  cout << ans;
  return 0;
}
