#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m, i, x, y, min, s = 0;
  cin >> n >> k >> m;
  string s1[n], s2[m];
  long long a[n];
  for (i = 0; i < n; ++i) cin >> s1[i];
  for (i = 0; i < n; ++i) cin >> a[i];
  map<string, long long> m1;
  long long g[k];
  for (i = 0; i < k; ++i) {
    cin >> x;
    min = 1e9;
    while (x--) {
      cin >> y;
      m1[s1[y - 1]] = i;
      if (a[y - 1] < min) min = a[y - 1];
    }
    g[i] = min;
  }
  for (i = 0; i < m; i++) {
    cin >> s2[i];
    s += g[m1[s2[i]]];
  }
  cout << s;
  return 0;
}
