#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
long long Min[N], cost[N];
map<string, int> mp;
map<int, int> f;
signed main() {
  ios::sync_with_stdio(false);
  int n, k, m;
  cin >> n >> k >> m;
  memset(Min, -1, sizeof(Min));
  for (int i = 1; i <= n; i++) {
    string str;
    cin >> str;
    mp[str] = i;
  }
  for (int i = 1; i <= n; i++) cin >> cost[i];
  for (int i = 1, x, y; i <= k; i++) {
    cin >> x;
    while (x--) {
      cin >> y;
      f[y] = i;
      if (Min[i] == -1)
        Min[i] = cost[y];
      else
        Min[i] = min(Min[i], cost[y]);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    string str;
    cin >> str;
    int groups = f[mp[str]];
    ans += Min[groups];
  }
  cout << ans << "\n";
  return 0;
}
