#include <bits/stdc++.h>
using namespace std;
class dsu {
 public:
  int n;
  vector<int> p;
  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }
  int find(int x) { return (x == p[x]) ? x : (p[x] = find(p[x])); }
  inline bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  dsu g = dsu(n + 1);
  string s;
  map<string, int> si;
  for (int i = 1; i <= n; ++i) {
    cin >> s;
    si[s] = i;
  }
  vector<long long> cost(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> cost[i];
  }
  int x;
  vector<int> mb(n + 1);
  for (int i = 0; i < k; ++i) {
    cin >> x;
    for (int j = 0; j < x; ++j) {
      cin >> mb[j];
      if (j) {
        if (cost[g.find(mb[j])] > cost[g.find(mb[j - 1])]) {
          g.unite(mb[j], mb[j - 1]);
        } else {
          g.unite(mb[j - 1], mb[j]);
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    ans += cost[g.find(si[s])];
  }
  cout << ans << '\n';
  return 0;
}
