#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  string s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  map<string, long long> make_pair;
  long long val[k];
  for (long long i = 0; i < k; i++) {
    long long t, t1, min = 1000000007;
    cin >> t;
    for (long long j = 0; j < t; j++) {
      cin >> t1;
      t1--;
      make_pair[s[t1]] = i;
      if (min > a[t1]) min = a[t1];
    }
    val[i] = min;
  }
  long long sum = 0;
  string s1;
  for (long long i = 0; i < m; i++) {
    cin >> s1;
    long long p = make_pair[s1];
    sum = sum + val[p];
  }
  cout << sum;
}
