#include <bits/stdc++.h>
using namespace std;
string s;
map<string, int> mp;
const int N = 1e5 + 5;
int a[N];
int cost[N];
int g[N];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    mp[s] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int x;
  int minn;
  while (k--) {
    scanf("%d", &x);
    minn = 0x3f3f3f3f;
    for (int i = 0; i < x; i++) {
      scanf("%d", &g[i]);
      minn = min(minn, a[g[i]]);
    }
    for (int i = 0; i < x; i++) {
      cost[g[i]] = minn;
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> s;
    ans += cost[mp[s]];
  }
  printf("%lld\n", ans);
  return 0;
}
