#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n, m;
  cin >> n >> k >> m;
  vector<pair<string, int> > s;
  int ni = n;
  while (ni > 0) {
    string r;
    cin >> r;
    s.push_back(pair<string, int>(r, 0));
    ni--;
  }
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    s[i].second = k;
  }
  while (k > 0) {
    int f;
    cin >> f;
    int a[f], m = INT_MAX;
    for (int i = 0; i < f; i++) {
      cin >> a[i];
      m = min(m, s[a[i] - 1].second);
    }
    for (int i = 0; i < f; i++) {
      s[a[i] - 1].second = m;
    }
    k--;
  }
  map<string, int> q;
  while (n > 0) {
    q.insert(pair<string, int>(s[n - 1].first, s[n - 1].second));
    n--;
  }
  long long int sum = 0;
  while (m > 0) {
    string h;
    cin >> h;
    sum = sum + q.find(h)->second;
    m--;
  }
  cout << sum;
  return 0;
}
