#include <bits/stdc++.h>
using namespace std;
string s;
map<string, int> mp;
map<string, int> id;
int kunset[100005];
int mn[100005];
int a[100005];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n, m, k, x;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) cin >> s, mp[s] = i;
  for (int i = 1; i <= n; i++) cin >> a[i], mn[i] = 1e9 + 5;
  for (int i = 1, j; i <= k; i++) {
    cin >> x;
    while (x--) cin >> j, kunset[j] = i, mn[i] = min(mn[i], a[j]);
  }
  long long ans = 0;
  while (cin >> s) {
    ans += mn[kunset[mp[s]]];
  }
  cout << ans;
}
