#include <bits/stdc++.h>
using namespace std;
int p[100005], sz[100005];
long long lo[100005];
map<string, int> id;
void make_sets(int n) {
  for (int i = 1; i <= n; i++) p[i] = i, sz[i] = 1;
}
int find(int x) {
  if (x == p[x]) return x;
  return x = find(p[x]);
}
void union_sets(int a, int b) {
  a = find(a), b = find(b);
  if (a != b) {
    if (sz[a] < sz[b]) swap(a, b);
    sz[a] += sz[b];
    lo[a] = min(lo[a], lo[b]);
    p[b] = a;
  }
}
int main() {
  int n, m, k, t, w1, w2;
  long long ans = 0;
  string w;
  cin >> n >> k >> m;
  make_sets(n);
  for (int i = 1; i <= n; i++) {
    cin >> w;
    id[w] = i;
  }
  for (int i = 1; i <= n; i++) cin >> lo[i];
  while (k--) {
    cin >> t;
    if (t) cin >> w1;
    for (int i = 1; i < t; i++) {
      cin >> w2;
      union_sets(w1, w2);
    }
  }
  while (m--) {
    cin >> w;
    ans += lo[find(id[w])];
  }
  cout << ans;
  return 0;
}
