#include <bits/stdc++.h>
using namespace std;
unordered_map<string, long> v;
int n, m, k;
vector<int> comp;
vector<int> par, rnk;
unordered_map<int, int> mn;
void init() {
  int i;
  par.resize(n);
  rnk.resize(n);
  par.clear();
  rnk.clear();
  for (i = 0; i < n; i++) {
    par[i] = i;
    rnk[i] = 1;
  }
}
int find_set(int i) {
  int j = i;
  while (par[j] != j) j = par[j];
  par[i] = j;
  return j;
}
void union_set(int i, int j) {
  int si = find_set(i), sj = find_set(j);
  if (si == sj) return;
  if (rnk[j] > rnk[i]) swap(i, j), swap(si, sj);
  mn[si] = min(mn[si], mn[sj]);
  mn.erase(mn.find(sj));
  par[find_set(j)] = par[find_set(i)];
  rnk[find_set(i)] += rnk[find_set(j)];
}
int main() {
  long long ans = 0;
  int i, j, a, b, x;
  cin >> n >> k >> m;
  init();
  string s[n], t;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    cin >> a;
    v[s[i]] = i;
    mn[i] = a;
  }
  for (i = 0; i < k; i++) {
    cin >> x;
    cin >> a;
    a--;
    for (j = 1; j < x; j++) {
      cin >> b;
      b--;
      union_set(a, b);
      a = b;
    }
  }
  for (i = 0; i < m; i++) {
    cin >> t;
    ans += mn[find_set(v[t])];
  }
  cout << ans;
}
