#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, long long> slovar;
  long long n, k, m;
  cin >> n >> k >> m;
  for (long long i = 1; i <= n; i++) {
    string h;
    cin >> h;
    slovar.insert(pair<string, long long>(h, i));
  }
  long long pay[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> pay[i];
  }
  for (long long i = 0; i < k; i++) {
    long long q;
    cin >> q;
    long long w[q];
    long long min = 1000000000;
    for (long long j = 0; j < q; j++) {
      cin >> w[j];
      if (pay[w[j]] < min) min = pay[w[j]];
    }
    for (long long j = 0; j < q; j++) {
      pay[w[j]] = min;
    }
  }
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    string z;
    cin >> z;
    sum += pay[slovar.find(z)->second];
  }
  cout << sum;
  return 0;
}
