#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k, m;
  cin >> n >> k >> m;
  map<string, long long int> sll;
  vector<string> words(n);
  vector<long long int> val(n);
  for (long long int i = 0; i < n; i++) cin >> words[i];
  for (long long int i = 0; i < n; i++) cin >> val[i];
  for (long long int i = 0; i < n; i++) sll[words[i]] = val[i];
  while (k--) {
    long long int siz;
    cin >> siz;
    long long int mingro = 1000000007;
    vector<long long int> gro(siz);
    for (long long int i = 0; i < siz; i++) {
      cin >> gro[i];
      gro[i]--;
      mingro = min(mingro, sll[words[gro[i]]]);
    }
    for (long long int i = 0; i < siz; i++) sll[words[gro[i]]] = mingro;
  }
  long long int ans(0);
  while (m--) {
    string s;
    cin >> s;
    ans += sll[s];
  }
  cout << ans;
  return 0;
}
