#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
long long int power(long long int base, long long int exp) {
  long long int res = 1;
  while (exp) {
    if (exp % 2) res *= base;
    base *= base;
    res %= mod;
    base %= mod;
    exp /= 2;
  }
  return res;
}
string str[maxn];
long long int arr[maxn], val[maxn], p[maxn];
map<string, long long int> mp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, m, i, ans = 0;
  cin >> n >> k >> m;
  for (i = 1; i <= n; i++) {
    cin >> str[i];
    mp[str[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (i = 1; i <= k; i++) {
    long long int x;
    cin >> x;
    vector<long long int> v;
    long long int cost = mod;
    for (long long int j = 1; j <= x; j++) {
      long long int y;
      cin >> y;
      v.push_back(y);
      cost = min(cost, arr[y]);
    }
    sort(v.begin(), v.end());
    for (auto j : v) {
      p[j] = v[0];
    }
    val[v[0]] = cost;
  }
  for (i = 0; i < m; i++) {
    string s;
    cin >> s;
    long long int idx = mp[s];
    idx = p[idx];
    ans += val[idx];
  }
  cout << ans << "\n";
  return 0;
}
