#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, temp, x;
  long long total = 0;
  int cost[100005], arr[100005], group[100005];
  map<string, int> d;
  string str;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> str;
    d[str] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    cost[i] = INT_MAX;
  }
  for (int i = 1; i <= k; i++) {
    cin >> x;
    while (x--) {
      cin >> temp;
      group[temp] = i;
      cost[i] = min(cost[i], arr[temp]);
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> str;
    total += cost[group[d[str]]];
  }
  cout << total << endl;
  return 0;
}
