#include <bits/stdc++.h>
using namespace std;
map<string, long long> mid;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k, m;
  cin >> n >> k >> m;
  string s[n];
  for (long long i = 0; i < n; ++i) {
    cin >> s[i];
    mid[s[i]] = i;
  }
  long long a[n];
  long long par[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < k; ++i) {
    long long x;
    cin >> x;
    vector<long long> v;
    long long idx = -1;
    long long cost = 1e9 + 7;
    for (long long i = 0; i < x; ++i) {
      long long temp;
      cin >> temp;
      if (a[temp - 1] < cost) {
        cost = a[temp - 1];
        idx = temp - 1;
      }
      v.push_back(temp);
    }
    for (auto j : v) {
      par[j - 1] = idx;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; ++i) {
    string fg;
    cin >> fg;
    ans += a[par[mid[fg]]];
  }
  cout << ans;
}
