#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int group[N], cost[N], gc[N];
map<string, int> id;
int main() {
  fill(gc, gc + N, 1e9 + 8);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    id[s] = i;
  }
  for (int i = 1; i <= n; i++) cin >> cost[i];
  for (int i = 1; i <= k; i++) {
    int sz;
    cin >> sz;
    for (int j = 1; j <= sz; j++) {
      int x;
      cin >> x;
      group[x] = i;
      gc[i] = min(gc[i], cost[x]);
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    ans += gc[group[id[s]]];
  }
  cout << ans << endl;
}
