#include <bits/stdc++.h>
using namespace std;
string str[100000 + 7];
int a[100000 + 7];
int b[100000 + 7];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> M;
  for (int i = 1; i <= n; i++) {
    cin >> str[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= k; i++) {
    int j, temp;
    long long int L = 10000000000;
    cin >> j;
    for (int k = 0; k < j; k++) {
      cin >> temp;
      M[str[temp]] = i;
      if (a[temp] < L) L = a[temp];
    }
    b[i] = L;
  }
  long long int sum = 0;
  string x;
  for (int i = 0; i < m; i++) {
    cin >> x;
    sum += b[M[x]];
  }
  cout << sum << endl;
}
