#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, l, p, q, r, ans = 0, n, m, t, x;
  cin >> n >> k >> r;
  vector<string> L;
  string s;
  map<string, int> m1;
  for (i = 0; i < n; i++) {
    cin >> s;
    L.push_back(s);
    m1[s] = i;
  }
  map<string, int> A;
  int B[n + 10];
  for (i = 0; i < n; i++) {
    cin >> p;
    B[i] = p;
  }
  for (i = 0; i < k; i++) {
    vector<int> C;
    cin >> x;
    m = INT_MAX;
    for (j = 0; j < x; j++) {
      cin >> q;
      q--;
      C.push_back(q);
      if (m > B[q]) m = B[q];
    }
    long long sz = C.size();
    for (t = 0; t < sz; t++) {
      B[C[t]] = m;
    }
  }
  for (i = 0; i < r; i++) {
    cin >> s;
    p = m1[s];
    ans += B[p];
  }
  cout << ans << endl;
}
