#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k, m;
  cin >> n >> k >> m;
  map<string, long long> s;
  for (long long i = 0; i < n; ++i) {
    string t;
    cin >> t;
    s[t] = i;
  }
  vector<long long> c(n), gc(k, (long long)1e9), g(n);
  for (long long i = 0; i < n; ++i) cin >> c[i];
  for (long long i = 0; i < k; ++i) {
    long long x;
    cin >> x;
    while (x--) {
      long long d;
      cin >> d;
      d--;
      gc[i] = min(gc[i], c[d]);
      g[d] = i;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; ++i) {
    string t;
    cin >> t;
    ans += gc[g[s[t]]];
  }
  cout << ans << '\n';
}
