#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> mp;
  map<int, int> mp2;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    mp[s] = i;
  }
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    mp2[i] = x;
  }
  while (k--) {
    int c = 9999999999;
    int x;
    cin >> x;
    int a[x + 2];
    for (int i = 1; i <= x; i++) {
      cin >> a[i];
      c = min(c, mp2[a[i]]);
    }
    for (int i = 1; i <= x; i++) {
      mp2[a[i]] = c;
    }
  }
  long long int sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> s;
    int x = mp[s];
    sum += mp2[x];
  }
  cout << sum << "\n";
}
