#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, k, m, x, r;
  long long int min;
  cin >> n >> k >> m;
  string s[n + 1], str;
  long long int grp[n + 1], cost[n + 1];
  map<string, int> map1;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    map1[s[i]] = i;
  }
  for (int i = 1; i <= n; i++) cin >> cost[i];
  for (int j = 1; j <= k; j++) {
    cin >> x;
    min = 1e+14;
    while (x--) {
      cin >> r;
      map1[s[r]] = j;
      if (cost[r] < min) min = cost[r];
    }
    grp[j] = min;
  }
  long long int ans = 0;
  for (int i = 1; i <= m; i++) {
    cin >> str;
    ans += grp[map1[str]];
  }
  cout << ans << "\n";
  return 0;
}
