#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
vector<int> groups[100005];
map<string, int> mp;
string str;
long long cost[100005];
int leader[100005];
int find_leader(int x) {
  if (leader[x] == x)
    return x;
  else
    return leader[x] = find_leader(leader[x]);
}
void merg(int x, int y) {
  int lx = find_leader(x);
  int ly = find_leader(y);
  if (cost[lx] > cost[ly])
    leader[lx] = ly;
  else
    leader[ly] = lx;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, m, i, x, y, a;
  cin >> n >> k >> m;
  for (i = 1; i <= n; i++) {
    cin >> str;
    mp[str] = i;
    leader[i] = i;
  }
  for (i = 1; i <= n; i++) cin >> cost[i];
  for (i = 1; i <= k; i++) {
    cin >> a;
    cin >> x;
    a--;
    while (a--) {
      cin >> y;
      merg(x, y);
    }
  }
  for (i = 1; i <= n; i++) groups[i].push_back(find_leader(i));
  long long ans = 0;
  int j, f, b;
  for (i = 1; i <= m; i++) {
    cin >> str;
    b = mp[str];
    f = groups[b][0];
    ans = ans + cost[f];
  }
  cout << ans << '\n';
  return 0;
}
