#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 50;
int n, k, m;
long long a[maxn];
string s[maxn];
map<string, long long> M;
queue<string> Q;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int num;
  for (int i = 1; i <= k; i++) {
    cin >> num;
    long long mn = INF;
    int x;
    while (num--) {
      cin >> x;
      Q.push(s[x]);
      mn = min(a[x], mn);
    }
    while (Q.size()) {
      M[Q.front()] = mn;
      Q.pop();
    }
  }
  string ss;
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    cin >> ss;
    ans += M[ss];
  }
  cout << ans << endl;
  return 0;
}
