#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, i, j, x;
  cin >> n >> k >> m;
  string s[n + 5];
  long long int cost[n + 5];
  map<string, int> mp;
  for (i = 1; i <= n; ++i) {
    cin >> s[i];
    mp[s[i]] = i;
  }
  for (i = 1; i <= n; ++i) cin >> cost[i];
  for (i = 1; i <= k; ++i) {
    cin >> x;
    vector<long long int> v;
    long long int arr[x + 5];
    for (j = 1; j <= x; ++j) {
      cin >> arr[j];
      v.push_back(cost[arr[j]]);
    }
    sort(v.begin(), v.end());
    for (j = 1; j <= x; ++j) {
      cost[arr[j]] = v[0];
    }
  }
  long long int ans = 0;
  string ss;
  for (i = 1; i <= m; ++i) {
    cin >> ss;
    ans += cost[mp[ss]];
  }
  cout << ans << "\n";
  return 0;
}
