#include <bits/stdc++.h>
using namespace std;
int a[100100];
char s[100100][22];
int mn[100100];
int te[100100];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> ind;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i]);
    string t = s[i];
    ind[t] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mn[i] = a[i];
  }
  for (int i = 0; i < k; i++) {
    int sz;
    scanf("%d", &sz);
    int mn1 = 1e9;
    for (int j = 0; j < sz; j++) {
      scanf("%d", &te[j]);
      mn1 = min(mn1, a[te[j]]);
    }
    for (int j = 0; j < sz; j++) {
      mn[te[j]] = min(mn1, mn[te[j]]);
    }
  }
  int64_t res = 0;
  for (int i = 0; i < m; i++) {
    scanf("%s", s[i]);
    string t = s[i];
    res += mn[ind[t]];
  }
  cout << res << endl;
  return 0;
}
