#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int mod = (int)1e9 + 7;
int a[N], p[N], sz[N], cost[N];
map<string, int> mp;
int get(int x) {
  while (x != p[x]) x = p[p[x]];
  return x;
}
void unite(int x, int y) {
  x = get(x);
  y = get(y);
  if (x != y) {
    if (sz[y] > sz[x]) swap(x, y);
    sz[x] += sz[y];
    p[y] = x;
    cost[x] = min(cost[x], cost[y]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, m;
  cin >> n >> k >> m;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    mp[s] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i] = i;
    sz[i] = 1;
    cost[i] = a[i];
  }
  int x, y, z;
  while (k--) {
    cin >> x >> y;
    x--;
    while (x--) {
      cin >> z;
      unite(y, z);
    }
  }
  long long ans = 0;
  while (m--) {
    cin >> s;
    x = mp[s];
    ans += cost[get(x)];
  }
  cout << ans;
  return 0;
}
