#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, k, m;
  cin >> n >> k >> m;
  vector<string> words(n);
  vector<long long> c(n);
  for (long long i = 0; i < n; i++) {
    cin >> words[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
  }
  map<string, long long> cost;
  for (long long i = 0; i < n; i++) {
    cost[words[i]] = c[i];
  }
  for (long long i = 0; i < k; i++) {
    long long x;
    cin >> x;
    vector<long long> indices(x);
    long long mnCost = 1e10;
    for (long long &ind : indices) {
      cin >> ind;
      ind--;
      mnCost = min(mnCost, cost[words[ind]]);
    }
    for (long long ind : indices) {
      cost[words[ind]] = mnCost;
    }
  }
  long long ans = 0;
  while (m--) {
    string w;
    cin >> w;
    ans += cost[w];
  }
  cout << ans;
  return 0;
}
