#include <bits/stdc++.h>
bool debug = true;
using namespace std;
int main(void) {
  if (0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  int n, m, k, x, tmp, i, j;
  scanf("%d %d %d", &n, &k, &m);
  string t;
  vector<string> a(n);
  vector<int> c(n, 0);
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) scanf("%d", &c[i]);
  vector<vector<int>> g(k);
  map<string, int> mp;
  for (i = 0; i < k; i++) {
    scanf("%d", &x);
    for (j = 0; j < x; j++) {
      scanf("%d", &tmp);
      g[i].push_back(c[tmp - 1]);
      mp[a[tmp - 1]] = i;
    }
    sort(g[i].begin(), g[i].end());
  }
  long long ans = 0;
  for (i = 0; i < m; i++) {
    cin >> t;
    x = mp[t];
    ans += g[x][0];
  }
  printf("%lld\n", ans);
}
