#include <bits/stdc++.h>
using namespace std;
int n, k, m;
string a[100005];
long long c[100005];
map<int, long long> mpp;
map<string, int> ms;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> c[i];
  for (int i = 1; i <= m; ++i) {
    int x, l;
    cin >> l;
    mpp[i] = 1e12;
    while (l--) {
      cin >> x;
      ms[a[x]] = i;
      mpp[i] = min(mpp[i], c[x]);
    }
  }
  long long ans = 0;
  while (k--) {
    string s;
    cin >> s;
    ans += mpp[ms[s]];
  }
  cout << ans << endl;
  return 0;
}
