#include <bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;
using ll = long long;
const int N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> k >> m;
  map<string, ll> mp;
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    mp[s] = i;
  }
  ll a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  deque<int> d;
  for (int i = 0; i < k; ++i) {
    int x, y;
    ll mi = 1e17;
    cin >> x;
    d.clear();
    for (int j = 0; j < x; ++j) {
      cin >> y;
      --y;
      mi = min(mi, a[y]);
      d.push_back(y);
    }
    for (auto it : d) a[it] = mi;
  }
  string msg;
  ll ans = 0;
  for (int i = 0; i < m; ++i) {
    cin >> msg;
    ans += a[mp[msg]];
  }
  cout << ans << "\n";
  return 0;
}
