#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long z, x, c;
  cin >> z >> x >> c;
  string a[z];
  long long s[x];
  long long e[z];
  string d;
  map<string, long long> asd;
  for (long long q = 0; q < z; q++) {
    cin >> a[q];
  }
  for (long long q = 0; q < z; q++) {
    cin >> e[q];
  }
  for (long long q = 0; q < x; q++) {
    long long r, t, v = 0;
    cin >> r;
    for (long long w = 0; w < r; w++) {
      cin >> t;
      asd[a[t - 1]] = q;
      if (w == 0)
        v = e[t - 1];
      else if (e[t - 1] < v)
        v = e[t - 1];
    }
    s[q] = v;
  }
  long long total = 0, g;
  for (long long q = 0; q < c; q++) {
    cin >> d;
    g = asd[d];
    total = total + s[g];
  }
  cout << total << endl;
}
