#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, k;
  cin >> n >> k >> m;
  map<string, long long int> mapping;
  string temp;
  for (int i = 1; i <= n; i++) {
    cin >> temp;
    mapping[temp] = i;
  }
  vector<long long int> cost(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> cost[i];
  }
  for (int i = 1; i <= k; i++) {
    long long int num_ele, minimum = 1e9;
    cin >> num_ele;
    vector<long long int> t(num_ele);
    for (int j = 0; j < num_ele; j++) {
      cin >> t[j];
      minimum = min(minimum, cost[t[j]]);
    }
    for (int j = 0; j < t.size(); j++) cost[t[j]] = minimum;
  }
  long long int count = 0;
  for (int i = 1; i <= m; i++) {
    cin >> temp;
    count += cost[mapping[temp]];
  }
  cout << count;
}
