#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int main() {
  int n, k, m;
  scanf("%d %d %d", &n, &k, &m);
  vector<string> v;
  vector<int> a;
  char str[100];
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    v.push_back(string(str));
    mp[v.back()] = i;
  }
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  for (int i = 0; i < k; i++) {
    int lim;
    scanf("%d", &lim);
    int cost = INT_MAX;
    vector<int> val;
    while (lim--) {
      int x;
      scanf("%d", &x);
      x--;
      val.push_back(x);
      cost = min(cost, a[x]);
    }
    for (auto x : val) {
      mp[v[x]] = cost;
    }
  }
  long long ans = 0LL;
  while (m--) {
    scanf("%s", str);
    ans += mp[string(str)];
  }
  printf("%lld\n", ans);
  return 0;
}
