#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k, m;
  cin >> n >> k >> m;
  string s[n + 1];
  long long a[n + 1];
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) cin >> a[i];
  long long x;
  long long b[n + 1];
  for (int i = 1; i <= k; i++) {
    cin >> x;
    long long ans = 1e9;
    for (int j = 1; j <= x; j++) {
      cin >> b[j];
      ans = min(ans, a[b[j]]);
    }
    for (int j = 1; j <= x; j++) a[b[j]] = ans;
  }
  map<string, long long> m1;
  string c;
  long long ans1 = 0;
  for (int i = 1; i <= n; i++) m1[s[i]] = a[i];
  for (int i = 1; i <= m; i++) {
    cin >> c;
    ans1 += m1[c];
  }
  cout << ans1;
}
