#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m, i, x, p = 0, kk = 100000000000000000, sum = 0;
  cin >> n >> k >> m;
  string me[n];
  map<string, long long> fahim;
  for (i = 0; i < n; i++) {
    cin >> me[i];
  }
  for (i = 0; i < n; i++) {
    cin >> fahim[me[i]];
  }
  for (i = 0; i < k; i++) {
    cin >> x;
    if (x == 1) {
      cin >> x;
      continue;
    }
    if (x != 1) {
      long long d[x];
      for (p = 0; p < x; p++) {
        cin >> d[p];
        kk = min(kk, fahim[me[d[p] - 1]]);
      }
      for (p = 0; p < x; p++) {
        fahim[me[d[p] - 1]] = kk;
      }
    }
    kk = 100000000000000000;
  }
  string word;
  for (i = 0; i < m; i++) {
    cin >> word;
    sum += fahim[word];
  }
  cout << sum;
}
