#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long int n, k, m;
    cin >> n >> k >> m;
    string group[n];
    long long int cost[n];
    for (long long int i = 0; i < n; i++) {
      cin >> group[i];
    }
    for (long long int i = 0; i < n; i++) {
      cin >> cost[i];
    }
    map<string, long long int> make_pair;
    for (long long int i = 0; i < n; i++) {
      make_pair[group[i]] = i;
    }
    while (k--) {
      long long int x;
      cin >> x;
      long long int arr[x];
      long long int mini = 1000000000000;
      for (long long int i = 0; i < x; i++) {
        cin >> arr[i];
        if (cost[arr[i] - 1] < mini) mini = cost[arr[i] - 1];
      }
      for (long long int i = 0; i < x; i++) {
        cost[arr[i] - 1] = mini;
      }
    }
    long long int ans = 0;
    for (long long int i = 0; i < m; i++) {
      string temp;
      cin >> temp;
      ans += cost[make_pair[temp]];
    }
    cout << ans;
  }
  return 0;
}
