#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  map<string, long long> arr;
  vector<string> key(n);
  for (long long i = 0; i < n; i++) {
    cin >> key[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> arr[key[i]];
  }
  for (long long i = 0; i < k; i++) {
    long long x, min = INF;
    cin >> x;
    vector<long long> e;
    for (long long i = 0; i < x; i++) {
      long long b;
      cin >> b;
      if (min > arr[key[--b]]) {
        min = arr[key[b]];
      }
      e.push_back(b);
    }
    for (long long i = 0; i < x; i++) {
      arr[key[e[i]]] = min;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    string y;
    cin >> y;
    ans += arr[y];
  }
  cout << ans << endl;
  return 0;
}
