#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> s;
  for (int i = 0; i < n; ++i) {
    string v;
    cin >> v;
    s[v] = i;
  }
  vector<int> b(n);
  for (int i = 0; i < n; ++i) cin >> b[i];
  vector<int> c(k);
  vector<int> g(n);
  for (int i = 0; i < k; ++i) {
    int x;
    cin >> x;
    int best = 2e9;
    while (x--) {
      int idx;
      cin >> idx;
      idx--;
      g[idx] = i;
      best = min(best, b[idx]);
    }
    c[i] = best;
  }
  ll ans = 0;
  for (int i = 0; i < m; ++i) {
    string v;
    cin >> v;
    ans += c[g[s[v]]];
  }
  cout << ans;
}
