#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, k, m;
  cin >> n >> k >> m;
  string a[100000 + 5];
  map<string, int> mp;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> mp[a[i]];
  }
  for (int i = 0; i < k; i++) {
    int a1[100000 + 5];
    int tem, minn = 0x3f3f3f3f;
    cin >> tem;
    for (int j = 0; j < tem; j++) {
      cin >> a1[j];
      if (mp[a[a1[j]]] < minn) minn = mp[a[a1[j]]];
    }
    for (int j = 0; j < tem; j++) {
      mp[a[a1[j]]] = minn;
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    string d;
    cin >> d;
    ans += mp[d];
  }
  cout << ans << endl;
}
