#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k, m, ans = 0;
  cin >> n >> k >> m;
  char name[n + 5][100];
  long long valu[n + 5];
  map<string, int> mp1, mp2;
  for (long long i = 1; i <= n; ++i) cin >> name[i];
  for (long long i = 1; i <= n; ++i) cin >> valu[i], mp1[name[i]] = valu[i];
  for (long long i = 1; i <= k; ++i) {
    long long x;
    vector<int> vc;
    vector<string> st;
    cin >> x;
    for (long long j = 1; j <= x; ++j) {
      long long p;
      cin >> p;
      vc.push_back(p);
      st.push_back(name[p]);
    }
    long long s = vc.size(), choto = INT_MAX;
    for (long long i = 0; i < s; ++i) choto = min(choto, valu[vc[i]]);
    for (long long i = 0; i < s; ++i) mp1[name[vc[i]]] = choto;
  }
  char Name[100];
  for (long long i = 1; i <= m; ++i) cin >> Name, ans += mp1[Name];
  cout << ans << endl;
}
