#include <bits/stdc++.h>
using namespace std;
int n, m, k, a, b, x, c[100009];
string s[100009], ss;
unordered_map<string, int> mp;
long long ans;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    mp[s[i]] = c[i];
  }
  for (int i = 0; i < k; i++) {
    scanf("%d", &a);
    vector<int> v;
    int mn = 1e9 + 9;
    for (int j = 0; j < a; j++) {
      scanf("%d", &b);
      v.push_back(b);
      if (c[b] < mn) mn = c[b];
    }
    for (int q = 0; q < a; q++) mp[s[v[q]]] = mn;
  }
  for (int i = 0; i < m; i++) {
    cin >> ss;
    ans += mp[ss];
  }
  cout << ans;
}
