#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> M;
  string s;
  long long n, k, m, a, b, mn, a1, c = 0;
  cin >> n >> k >> m;
  vector<string> arr(n);
  vector<string> mp(0);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a;
    M[arr[i]] = a;
  }
  for (int i = 0; i < k; i++) {
    cin >> b;
    cin >> a1;
    mn = M[arr[a1 - 1]];
    mp.push_back(arr[a1 - 1]);
    for (int h = 1; h < b; h++) {
      cin >> a;
      mp.push_back(arr[a - 1]);
      if (M[arr[a - 1]] < mn) {
        mn = M[arr[a - 1]];
      }
    }
    for (int j = 0; j < mp.size(); j++) {
      M[mp[j]] = mn;
    }
    mp.clear();
  }
  for (int i = 0; i < m; i++) {
    cin >> s;
    c += M[s];
  }
  cout << c;
}
