#include <bits/stdc++.h>
using namespace std;
void smain();
int main() {
  ios::sync_with_stdio(false);
  smain();
  return 0;
}
map<string, int> M;
const int MAXN = 1e5 + 10;
const long long INF = 2e9;
string str[MAXN];
long long cost[MAXN];
int tmp[MAXN];
void smain() {
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = (1); i <= (n); ++i) {
    cin >> str[i];
    M[str[i]] = i;
  }
  for (int i = (1); i <= (n); ++i) {
    cin >> cost[i];
  }
  for (int i = (1); i <= (k); ++i) {
    int K;
    cin >> K;
    long long mc = INF;
    for (int j = (1); j <= (K); ++j) {
      cin >> tmp[j];
      mc = min(mc, cost[tmp[j]]);
    }
    for (int j = (1); j <= (K); ++j) cost[tmp[j]] = mc;
  }
  string s;
  long long ans = 0;
  for (int i = (1); i <= (m); ++i) {
    cin >> s;
    ans += cost[M[s]];
  }
  cout << ans << endl;
}
