#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int n, k, m, a[100012], fa[100012], c[100012];
char s[30];
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    mp[s] = i;
    fa[i] = i;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= k; i++) {
    int x, a, b;
    scanf("%d", &x);
    scanf("%d", &a);
    for (int i = 2; i <= x; i++) {
      scanf("%d", &b);
      int p = find(a), q = find(b);
      fa[p] = q;
      c[q] = min(c[q], c[p]);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    ans += c[find(mp[s])];
  }
  printf("%lld\n", ans);
  return 0;
}
