#include <bits/stdc++.h>
using namespace std;
string cad[100001];
map<string, int> mapa;
long long int costo[100001];
vector<long long int> vec;
int main() {
  long long int n, m, k, i, j, r, indice;
  string cad2;
  cin >> n >> k >> m;
  for (i = 1; i <= n; i++) {
    cin >> cad[i];
    mapa[cad[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    cin >> costo[i];
  }
  for (i = 1; i <= k; i++) {
    cin >> r;
    long long int mincost = 10000000000;
    for (j = 1; j <= r; j++) {
      cin >> indice;
      vec.push_back(indice);
      mincost = min(mincost, costo[indice]);
    }
    for (j = 1; j <= r; j++) {
      costo[vec[j - 1]] = mincost;
    }
    vec.clear();
  }
  long long int total = 0;
  for (i = 0; i < m; i++) {
    cin >> cad2;
    total += costo[mapa[cad2]];
  }
  cout << total;
}
