#include <bits/stdc++.h>
using namespace std;
struct HEAP_CMP {
  bool operator()(long long a, long long b) { return a > b; }
};
const long long M = 1e5 + 7;
const long long mod = 1e9;
const long double esp = 1e-5;
long long n, k, m, kk;
string s[M], ss;
long long x, a[M], ans;
map<string, long long> mp;
vector<long long> g;
void solve() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= k; i++) {
    cin >> x;
    long long mi = LLONG_MAX;
    g.clear();
    for (int j = 1; j <= x; j++) {
      cin >> kk;
      g.push_back(kk);
      mi = min(mi, a[kk]);
    }
    for (int j = 0; j < g.size(); j++) mp[s[g[j]]] = mi;
  }
  for (int i = 1; i <= m; i++) {
    cin >> ss;
    ans += mp[ss];
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
