#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k, m, i, j;
  cin >> n >> k >> m;
  vector<string> w(n + 1);
  vector<long long> c(n + 1);
  for (i = 1; i <= n; i++) cin >> w[i];
  for (i = 1; i <= n; i++) cin >> c[i];
  vector<long long> mc(k + 1);
  for (i = 1; i <= k; i++) {
    long long x;
    cin >> x;
    pair<long long, long long> p[x];
    for (j = 0; j < x; j++) {
      long long q;
      cin >> q;
      p[j].first = c[q];
      p[j].second = q;
    }
    sort(p, p + x);
    long long cost = p[0].first;
    for (j = 0; j < x; j++) c[p[j].second] = cost;
  }
  pair<string, long long> p[n];
  for (i = 0; i < n; i++) p[i].first = w[i + 1], p[i].second = c[i + 1];
  sort(p, p + n);
  long long tot = 0;
  while (m--) {
    string s;
    cin >> s;
    long long lo = 0, hi = n - 1;
    while (hi - lo > 1) {
      long long mid = (hi + lo) / 2;
      if (p[mid].first >= s)
        hi = mid;
      else
        lo = mid;
    }
    if (p[lo].first == s)
      tot += p[lo].second;
    else if (p[hi].first == s)
      tot += p[hi].second;
  }
  cout << tot << endl;
}
