#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int root[100005];
int ans[100005], num[100005];
string s;
int main() {
  int n, m, k, x, y;
  long long gg = 0;
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    cin >> s;
    mp[s] = i;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &x);
    ans[i] = 1000000007;
    while (x--) {
      scanf("%d", &y);
      root[y] = i;
      ans[i] = min(ans[i], num[y]);
    }
  }
  while (m--) {
    cin >> s;
    gg += ans[root[mp[s]]];
  }
  printf("%lld\n", gg);
  return 0;
}
