#include <bits/stdc++.h>
using namespace std;
string words[100005];
int cost[100005];
int main(int argc, const char* argv[]) {
  unordered_map<string, int> words_map;
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 0; i < n; ++i) {
    cin >> words[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> cost[i];
  }
  int x, m_cost, tmp;
  vector<int> tmp_v;
  for (int i = 0; i < k; ++i) {
    cin >> x;
    m_cost = 1000000005;
    tmp_v.clear();
    for (int j = 0; j < x; ++j) {
      cin >> tmp;
      tmp_v.push_back(tmp - 1);
      if (cost[tmp - 1] < m_cost) {
        m_cost = cost[tmp - 1];
      }
    }
    for (int j = 0; j < tmp_v.size(); ++j) {
      words_map[words[tmp_v[j]]] = m_cost;
    }
  }
  string word1;
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    cin >> word1;
    ans += words_map[word1];
  }
  cout << ans << endl;
  return 0;
}
