#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(1e5) + 100;
const int inf = 0x3f3f3f3f;
const int mod = 2520;
const double eps = 1e-3;
map<string, int> mp;
int val[maxn], gval[maxn];
struct unionfind {
  int pre[maxn], ranks[maxn];
  int find(int x) {
    if (pre[x] == x)
      return x;
    else
      return pre[x] = find(pre[x]);
  }
  void unite(int a, int b) {
    int x = find(a), y = find(b);
    if (x == y) return;
    if (ranks[x] < ranks[y])
      pre[x] = y;
    else {
      pre[y] = x;
      if (ranks[x] == ranks[y]) ranks[x]++;
    }
    return;
  }
  void init(int n) {
    for (int i = 0; i <= n; i++) {
      pre[i] = i;
      ranks[i] = 0;
    }
  }
} un;
char str[25];
int main() {
  int n, m, k;
  while (~scanf("%d%d%d", &n, &k, &m)) {
    un.init(n);
    mp.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%s", str);
      string s = str;
      mp[s] = i;
    }
    for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
    int x, y, st;
    while (k--) {
      scanf("%d%d", &x, &st);
      for (int i = 1; i < x; i++) {
        scanf("%d", &y);
        un.unite(st, y);
      }
    }
    memset(gval, 0x3f, sizeof(gval));
    for (int i = 1; i <= n; i++) {
      gval[un.find(i)] = min(gval[un.find(i)], val[i]);
    }
    long long ans = 0;
    for (int i = 0; i < m; i++) {
      scanf("%s", str);
      string s = str;
      x = mp[s];
      y = un.find(x);
      ans += gval[y];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
