#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  map<string, int> mp;
  vector<pair<string, int> > v(n);
  vector<int> cost(n);
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    v[i].first = str;
    mp[str] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
  }
  vector<int> mn(m);
  for (int i = 0; i < m; i++) {
    int x, mx;
    cin >> x;
    cin >> mx;
    v[mx - 1].second = i;
    mx = cost[mx - 1];
    for (int j = 1; j < x; j++) {
      int pos;
      cin >> pos;
      v[pos - 1].second = i;
      if (cost[pos - 1] < mx) mx = cost[pos - 1];
    }
    mn[i] = mx;
  }
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    string str;
    cin >> str;
    sum += mn[v[mp[str]].second];
  }
  cout << sum;
  return 0;
}
