#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> mp;
  int cost[n + 1];
  for (int i = 1; i <= n; i++) {
    string a;
    cin >> a;
    mp[a] = i;
  }
  for (int i = 1; i <= n; i++) cin >> cost[i];
  int ind = 1;
  int grp[100010] = {};
  int grpcst[k + 10];
  while (k--) {
    int x;
    cin >> x;
    int m = 1e9;
    m += 100;
    while (x--) {
      int temp;
      cin >> temp;
      m = min(m, cost[temp]);
      grp[temp] = ind;
    }
    grpcst[ind] = m;
    ind++;
  }
  long long int res = 0;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    int v = mp[s];
    if (grp[v] == 0) {
      res += cost[v];
    } else {
      res += grpcst[grp[v]];
    }
  }
  cout << res << endl;
}
