#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  string s[n];
  int p[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int j = 0; j < k; j++) {
    int x, min = INT_MAX;
    cin >> x;
    int arr[x];
    for (int i = 0; i < x; i++) {
      cin >> arr[i];
      if (p[arr[i] - 1] < min) min = p[arr[i] - 1];
    }
    for (int i = 0; i < x; i++) p[arr[i] - 1] = min;
  }
  string s1;
  map<string, int> str;
  for (int i = 0; i < n; i++) str[s[i]] = p[i];
  long long cost = 0;
  for (int i = 0; i < m; i++) {
    cin >> s1;
    cost += str[s1];
  }
  cout << cost;
  return 0;
}
