#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
map<string, int> Mp;
long long int price[100000 + 10];
long long int N, K, M;
void init() { Mp.clear(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t, kase = 0, a, b, i, j, l;
  vector<int> vc;
  while (cin >> N >> K >> M) {
    init();
    string str;
    for (i = 1; i <= N; i++) {
      cin >> str;
      Mp[str] = i;
    }
    for (i = 1; i <= N; i++) cin >> price[i];
    while (K--) {
      cin >> a;
      vc.clear();
      long long int mini = 1000000009;
      for (i = 0; i < a; i++) {
        cin >> b;
        vc.push_back(b);
        mini = min(mini, price[b]);
      }
      for (i = 0; i < a; i++) price[vc[i]] = mini;
    }
    int it;
    long long int ans = 0;
    for (i = 0; i < M; i++) {
      cin >> str;
      it = Mp[str];
      ans += price[it];
    }
    cout << ans << endl;
  }
  return 0;
}
