#include <bits/stdc++.h>
using namespace std;
int father[100009];
int maxi[100009];
map<string, int> mp;
int find(int x) {
  if (x == father[x]) {
    return x;
  }
  father[x] = find(father[x]);
  maxi[father[x]] = min(maxi[father[x]], maxi[x]);
  return father[x];
}
int a[100009];
int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  string s[100009];
  for (int i = 1; i <= n; i++) {
    father[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    maxi[i] = a[i];
    mp[s[i]] = i;
  }
  for (int i = 1; i <= k; i++) {
    int x, cnt;
    scanf("%d%d", &cnt, &x);
    if (cnt == 1) continue;
    for (int j = 1; j <= cnt - 1; j++) {
      int y;
      scanf("%d", &y);
      int fx = find(x);
      int fy = find(y);
      if (fx != fy) {
        father[fx] = fy;
        maxi[father[fx]] = min(maxi[fx], maxi[fy]);
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    string tmp;
    cin >> tmp;
    int u = mp[tmp];
    int fu = find(u);
    ans += (long long)maxi[fu];
  }
  cout << ans << endl;
  return 0;
}
