#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k, m;
  cin >> n >> k >> m;
  vector<string> v;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  long long a[n], l = 0;
  map<string, long long> mp;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    mp[v[i]] = a[i];
    l = max(l, a[i]);
  }
  for (long long i = 0; i < k; i++) {
    long long x;
    cin >> x;
    long long b[x];
    long long k = l;
    for (long long i = 0; i < x; i++) {
      cin >> b[i];
      k = min(k, a[b[i] - 1]);
    }
    for (long long i = 0; i < x; i++) mp[v[b[i] - 1]] = k;
  }
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    string s;
    cin >> s;
    sum += mp[s];
  }
  cout << sum << endl;
}
