#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int co[100005], idx[100005];
int main() {
  int N, K, M;
  string s;
  cin >> N >> K >> M;
  for (int i = 1; i <= N; i++) {
    cin >> s;
    m[s] = i;
  }
  int cost;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &co[i]);
  }
  for (int i = 1; i <= K; i++) {
    int min_cost = 1e9;
    scanf("%d", &N);
    for (int j = 1; j <= N; j++) {
      scanf("%d", &idx[j]);
      min_cost = min(co[idx[j]], min_cost);
    }
    for (int j = 1; j <= N; j++) co[idx[j]] = min_cost;
  }
  long long ans = 0;
  for (int i = 0; i < M; i++) {
    cin >> s;
    ans += (long long)co[m[s]];
  }
  printf("%lld\n", ans);
  return 0;
}
