#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  string str[n];
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  map<string, long long> mp;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    mp[str[i]] = x;
  }
  for (long long i = 0; i < k; i++) {
    long long x;
    cin >> x;
    vector<long long> vec;
    long long mn = 1e10;
    for (long long j = 0; j < x; j++) {
      long long e;
      cin >> e;
      vec.push_back(e - 1);
      mn = min(mn, mp[str[e - 1]]);
    }
    for (long long z = 0; z < vec.size(); z++) {
      mp[str[vec[z]]] = mn;
    }
  }
  string tr[m];
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    cin >> tr[i];
    sum += mp[tr[i]];
  }
  cout << sum << endl;
}
