#include <bits/stdc++.h>
using namespace std;
int nsize = 0, gsize = 0, msize = 0;
long long g[100001];
map<string, int> m;
long long cost[100001];
int idx[100001];
int groupto[100001];
int main() {
  scanf("%d %d %d", &nsize, &gsize, &msize);
  int i = 0;
  while (i < nsize) {
    string cur;
    cin >> cur;
    m[cur] = i;
    i++;
  }
  i = 0;
  while (i < nsize) {
    scanf("%lld", &cost[i]);
    i++;
  }
  i = 0;
  while (i < gsize) {
    int cnt;
    scanf("%d", &cnt);
    while (cnt--) {
      int temp;
      scanf("%d", &temp);
      temp--;
      groupto[temp] = i;
      if (g[i] == 0 || g[i] > cost[temp]) g[i] = cost[temp];
    }
    i++;
  }
  long long ans = 0;
  i = 0;
  while (i < msize) {
    string cur;
    cin >> cur;
    int tempidx = groupto[m[cur]];
    ans += g[tempidx];
    i++;
  }
  printf("%lld\n", ans);
  return 0;
}
