#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, k, m;
  cin >> n >> k >> m;
  string word;
  unordered_map<string, int> um;
  vector<string> v(n);
  vector<int> cost(n);
  for (int i = 0; i < n; i++) {
    cin >> word;
    um[word] = INT_MAX;
    v[i] = word;
  }
  for (int i = 0; i < n; i++) cin >> cost[i];
  int count, pos;
  for (int i = 0; i < k; i++) {
    cin >> count;
    vector<int> temp(count);
    int heremin = INT_MAX;
    for (int j = 0; j < count; j++) {
      cin >> pos;
      pos--;
      temp[j] = pos;
      heremin = min(cost[pos], heremin);
    }
    for (int j = 0; j < count; j++) {
      um[v[temp[j]]] = heremin;
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> word;
    ans += um[word];
  }
  cout << ans;
}
