#include <bits/stdc++.h>
using namespace std;
string word[100005];
long long int val[100005];
int group[100005];
map<string, long long int> mp;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> word[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
  }
  int x;
  long long int mn = INT_MAX;
  for (int i = 1; i <= k; i++) {
    cin >> x;
    mn = INT_MAX;
    for (int j = 1; j <= x; j++) {
      cin >> group[j];
      mn = min(mn, val[group[j]]);
    }
    for (int j = 1; j <= x; j++) {
      val[group[j]] = mn;
    }
  }
  for (int i = 1; i <= n; i++) {
    mp[word[i]] = val[i];
  }
  long long int total = 0;
  string ms;
  for (int i = 1; i <= m; i++) {
    cin >> ms;
    total += mp[ms];
  }
  cout << total;
  return 0;
}
