#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<string> words;
  words.push_back("____jj");
  long long cost[n + 1];
  unordered_map<string, long long> u;
  for (int i = 0; i < n; ++i) {
    string h;
    cin >> h;
    words.push_back(h);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> cost[i];
  }
  for (int i = 1; i <= n; ++i) {
    u[words[i]] = cost[i];
  }
  for (int i = 1; i <= k; i++) {
    int j;
    cin >> j;
    int arr[j + 1];
    long long min = 0;
    long long min_ind = 0;
    for (int l = 1; l <= j; l++) {
      cin >> arr[l];
      if (cost[arr[l]] < min) {
        min = cost[arr[l]];
        min_ind = arr[l];
      }
      if (min == 0) {
        min = cost[arr[l]];
        min_ind = arr[l];
      }
    }
    for (int p = 1; p <= j; ++p) {
      u[words[arr[p]]] = cost[min_ind];
    }
  }
  long long tot_cost = 0;
  for (int i = 0; i < m; ++i) {
    string d;
    cin >> d;
    tot_cost += u[d];
  }
  cout << tot_cost << "\n";
  return 0;
}
