#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 15;
const int INF = 1e9;
int n, k, m;
map<string, int> mp;
int cost[MaxN];
int group[MaxN], groupCost[MaxN];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k >> m;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    mp[s] = i;
  }
  for (int i = 1; i <= n; ++i) cin >> cost[i];
  for (int i = 1; i <= k; ++i) {
    int x;
    cin >> x;
    for (int j = 0; j < x; ++j) {
      int a;
      cin >> a;
      group[a] = i;
      groupCost[i] = min(cost[a], groupCost[i] ? groupCost[i] : INF);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; ++i) {
    string s;
    cin >> s;
    ans += groupCost[group[mp[s]]];
  }
  cout << ans << '\n';
  return 0;
}
