#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int a[100010];
int b[100010];
int main() {
  string str;
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> str;
    mp[str] = i;
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= k; i++) {
    int mn = 1e9;
    int sm = 0;
    cin >> sm;
    for (int i = 1; i <= sm; i++) cin >> b[i], mn = min(mn, a[b[i]]);
    for (int i = 1; i <= sm; i++) a[b[i]] = mn;
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    cin >> str;
    ans += a[mp[str]];
  }
  cout << ans << "\n";
  return 0;
}
