#include <bits/stdc++.h>
using namespace std;
class DSU {
 private:
  long long n;
  long long *id;
  long long *w;
  long long *mm;
  long long *arr;

 public:
  DSU(long long n, long long arr[]) {
    this->n = n;
    id = new long long[n + 1];
    w = new long long[n + 1];
    mm = new long long[n + 1];
    this->arr = arr;
    for (long long i = 0; i <= n; i++) {
      id[i] = i;
      w[i] = 1;
      mm[i] = arr[i];
    }
  }
  long long root(long long n) {
    while (n != id[n]) {
      id[n] = id[id[n]];
      n = id[n];
    }
    return n;
  }
  void unite(long long a, long long b) {
    long long aroot = root(a);
    long long broot = root(b);
    if (aroot == broot) return;
    if (w[aroot] < w[broot]) {
      id[aroot] = broot;
      w[broot] += w[aroot];
      mm[broot] = min(mm[broot], mm[aroot]);
    } else {
      id[broot] = aroot;
      w[aroot] += w[broot];
      mm[aroot] = min(mm[broot], mm[aroot]);
    }
  }
  long long ans(long long deepshri[], long long m) {
    long long answer = 0;
    for (long long i = 0; i < m; i++) {
      answer += mm[root(deepshri[i])];
    }
    return answer;
  }
};
int main() {
  long long t, k, m;
  cin >> t >> k >> m;
  map<string, long long> mp;
  long long arr[t];
  for (long long i = 0; i < t; i++) {
    string s;
    cin >> s;
    mp[s] = i;
  }
  for (long long i = 0; i < t; i++) cin >> arr[i];
  DSU dsu(t, arr);
  for (long long i = 0; i < k; i++) {
    long long nums;
    cin >> nums;
    long long ar[nums];
    cin >> ar[0];
    dsu.unite(ar[0] - 1, ar[0] - 1);
    for (long long i = 1; i < nums; i++) {
      cin >> ar[i];
      dsu.unite(ar[i] - 1, ar[i - 1] - 1);
    }
  }
  long long deepshri[m];
  for (long long i = 0; i < m; i++) {
    string s;
    cin >> s;
    deepshri[i] = mp[s];
  }
  cout << dsu.ans(deepshri, m);
}
