#include <bits/stdc++.h>
using namespace std;
long long pos[100005];
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<string> nstr;
  vector<long long> ncost;
  map<string, long long> nstrcost;
  string str;
  for (int i = 0; i < n; i++) {
    cin >> str;
    nstr.push_back(str);
  }
  long long cost;
  for (int i = 0; i < n; i++) {
    cin >> cost;
    ncost.push_back(cost);
  }
  long long p, mincost, kn;
  for (int i = 0; i < k; i++) {
    mincost = INT_MAX;
    cin >> kn;
    for (int j = 0; j < kn; j++) {
      cin >> p;
      pos[j] = p;
      mincost = min(mincost, ncost[p - 1]);
    }
    for (int h = 0; h < kn; h++) {
      nstrcost[nstr[pos[h] - 1]] = mincost;
      pos[h] = 0;
    }
  }
  long long sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> str;
    sum += nstrcost[str];
  }
  cout << sum << endl;
}
