#include <bits/stdc++.h>
using namespace std;
struct word {
  string s;
  int cost;
};
void solve() {
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> t;
  vector<string> words(n);
  vector<int> cost(n);
  for (auto &v : words) cin >> v;
  for (auto &v : cost) cin >> v;
  for (int i = 0; i < n; i++) {
    t[words[i]] = cost[i];
  }
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    vector<int> tmp(x);
    for (int j = 0; j < x; j++) {
      cin >> tmp[j];
      tmp[j]--;
    }
    int cur_min_index = tmp[0];
    for (int j = 1; j < x; j++) {
      if (cost[tmp[j]] < cost[cur_min_index]) {
        cur_min_index = tmp[j];
      }
    }
    for (int j = 0; j < x; j++) {
      if (tmp[j] != cur_min_index) {
        t[words[tmp[j]]] = cost[cur_min_index];
      }
    }
  }
  int64_t ans = 0;
  for (int i = 0; i < m; i++) {
    string w;
    cin >> w;
    ans += t[w];
  }
  cout << ans << '\n';
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
}
