#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
};
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, rge<T> d) {
  os << "[";
  for (auto it = d.b; it != d.e; it++) os << (it == d.b ? "" : ", ") << *it;
  return os << "]";
}
const int N = 1e5 + 5;
long long n, k, m;
string word[N];
long long cost[N];
map<string, long long> mp;
struct dsu {
  vector<long long> pr;
  vector<long long> mi;
  dsu(long long n) {
    pr.resize(n + 5);
    mi.resize(n + 5);
    for (int i = (0); i <= ((n + 5) - 1); i += (+1)) {
      pr[i] = i;
      mi[i] = 2e9;
    }
  }
  void unite(long long u, long long v) {
    u = find(u);
    v = find(v);
    if (u != v) {
      pr[u] = v;
      mi[v] = min(mi[u], mi[v]);
    }
  }
  long long find(long long u) {
    if (u == pr[u]) return u;
    return pr[u] = find(pr[u]);
  }
  long long operator[](long long u) { return find(u); }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
  cin >> n >> k >> m;
  dsu dg(n);
  for (int i = (1); i <= ((n)); i += (+1)) {
    cin >> word[i];
    mp[word[i]] = i;
  }
  for (int i = (1); i <= ((n)); i += (+1)) {
    cin >> dg.mi[i];
  }
  for (int i = (0); i <= ((k)-1); i += (+1)) {
    int x, u, v;
    cin >> x >> u;
    while (--x) {
      cin >> v;
      dg.unite(u, v);
    }
  }
  long long res = 0;
  string aux;
  for (int i = (0); i <= ((m)-1); i += (+1)) {
    cin >> aux;
    res += dg.mi[dg[mp[aux]]];
  }
  cout << res << '\n';
  return 0;
}
