#include <bits/stdc++.h>
const double EPS = 0.0000000001;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 7;
const long long mod3 = 1e9 + 9;
const long long mod4 = 228228227;
const long long inf = 1e16;
using namespace std;
void print(vector<long long>& v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
signed main() {
  long long n, a, b;
  cin >> n >> a >> b;
  string mass[n];
  for (long long i = 0; i < n; i++) cin >> mass[i];
  long long res[n];
  for (long long i = 0; i < n; i++) cin >> res[i];
  for (long long i = 0; i < a; i++) {
    long long x;
    cin >> x;
    long long c = inf;
    vector<long long> v;
    for (long long z = 0; z < x; z++) {
      long long y;
      cin >> y;
      c = min(c, res[y - 1]);
      v.push_back(y - 1);
    }
    for (long long z = 0; z < v.size(); z++) res[v[z]] = c;
  }
  map<string, long long> m;
  for (long long i = 0; i < n; i++) {
    m[mass[i]] = res[i];
  }
  long long ans = 0;
  for (long long i = 0; i < b; i++) {
    string s;
    cin >> s;
    ans += m[s];
  }
  cout << ans;
}
