#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<string> v;
  map<long long, long long> m3;
  map<string, long long> m1;
  map<long long, string> m2;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
  }
  for (int i = 0; i < n; i++) {
    long long d;
    cin >> d;
    m3[i + 1] = d;
    m1[v[i]] = d;
    m2[i + 1] = v[i];
  }
  for (int i = 0; i < k; i++) {
    long long min = LLONG_MAX;
    long long x;
    vector<long long> k;
    cin >> x;
    long long b;
    if (x == 1)
      cin >> b;
    else {
      for (int j = 0; j < x; j++) {
        cin >> b;
        k.push_back(b);
        if (m3[b] < min) min = m3[b];
      }
      for (int p = 0; p < k.size(); p++) {
        if (m1[m2[k[p]]] != min) m1[m2[k[p]]] = min;
      }
      k.clear();
    }
  }
  string d1;
  long long sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> d1;
    sum = sum + m1[d1];
  }
  cout << sum;
}
