#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> mp;
  vector<int> cost(n);
  for (int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    mp[str] = i;
  }
  for (int i = 0; i < n; ++i) {
    cin >> cost[i];
  }
  for (int i = 0; i < k; ++i) {
    int t, mn = INT_MAX;
    cin >> t;
    stack<int> st;
    while (t--) {
      int x;
      cin >> x;
      --x;
      st.push(x);
      mn = min(mn, cost[x]);
    }
    while (!st.empty()) {
      cost[st.top()] = mn;
      st.pop();
    }
  }
  long long sum = 0;
  for (int i = 0; i < m; ++i) {
    string str;
    cin >> str;
    sum += cost[mp[str]];
  }
  cout << sum;
}
