#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, k, m;
  cin >> n >> k >> m;
  vector<string> s(n);
  unordered_map<string, int> si;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    si[s[i]] = i;
  }
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < k; ++i) {
    int g;
    cin >> g;
    vector<int> sg;
    sg.resize(g);
    int min = INT_MAX;
    for (int i = 0; i < g; ++i) {
      cin >> sg[i];
      if (a[sg[i] - 1] < min) min = a[sg[i] - 1];
    }
    for (int i = 0; i < g; ++i) {
      a[sg[i] - 1] = min;
    }
  }
  string t;
  long long cost = 0;
  for (int i = 0; i < m; ++i) {
    cin >> t;
    cost = cost + (long long)a[si[t]];
  }
  cout << cost << endl;
  return 0;
}
