#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  vector<string> words(n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> words[i];
  for (int i = 0; i < n; ++i) cin >> a[i];
  map<string, int> group;
  map<int, int> cost;
  for (int i = 1; i <= k; ++i) {
    int x, tmp;
    cin >> x;
    cost[i] = 1e9 + 1;
    for (int j = 0; j < x; ++j) {
      cin >> tmp;
      group[words[tmp - 1]] = i;
      if (a[tmp - 1] < cost[i]) cost[i] = a[tmp - 1];
    }
  }
  string s;
  unsigned long long sum = 0;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    sum += cost[group[s]];
  }
  cout << sum;
  return 0;
}
