#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m, k;
  cin >> n >> k >> m;
  map<string, long long int> mp;
  for (long long int i = 0; i < n; ++i) {
    string temp;
    cin >> temp;
    mp.insert(make_pair(temp, i));
  }
  long long int cost[n];
  for (long long int i = 0; i < n; ++i) {
    cin >> cost[i];
  }
  vector<long long int> ind[k];
  for (long long int i = 0; i < k; ++i) {
    long long int num;
    cin >> num;
    long long int mm = LLONG_MAX;
    for (long long int j = 0; j < num; ++j) {
      long long int a;
      cin >> a;
      ind[i].push_back(a);
      ind[i][j] -= 1;
      mm = min(mm, cost[ind[i][j]]);
    }
    for (long long int j = 0; j < num; ++j) {
      cost[ind[i][j]] = mm;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < m; ++i) {
    string temp;
    cin >> temp;
    ans += cost[mp[temp]];
  }
  cout << ans << endl;
  return 0;
}
