#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
map<string, ll> Mp;
map<ll, string> Mp2;
ll a[100005];
ll cost[100005];
ll n, m, k;
string s;
void solve() {
  ll x, p;
  cin >> n >> k >> m;
  for (ll i = 1; i <= n; i++) {
    cin >> s;
    Mp[s] = i;
    Mp2[i] = s;
  }
  for (ll i = 1; i <= n; i++) cin >> a[i];
  for (ll i = 1; i <= k; i++) {
    ll tag, Min = INT_MAX;
    cin >> p;
    for (ll j = 1; j <= p; j++) {
      cin >> x;
      if (j == 1) tag = x;
      Min = min(a[x], Min);
      cost[tag] = Min;
      Mp[Mp2[x]] = tag;
    }
  }
  x = 0;
  for (ll i = 1; i <= m; i++) {
    cin >> s;
    x += cost[Mp[s]];
  }
  cout << x << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  solve();
  return 0;
}
