#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-11;
void fast() { std::ios_base::sync_with_stdio(0); }
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  map<string, int> s;
  string st;
  vector<string> stemp(n);
  for (int i = 0; i < n; i++) {
    cin >> st;
    s[st] = 0;
    stemp[i] = st;
  }
  vector<long long> cost(n);
  for (int i = 0; i < n; i++) scanf("%lld", &cost[i]);
  long long temp, x;
  vector<long long> mcg(k, 1e10);
  for (int i = 0; i < k; i++) {
    scanf("%lld", &temp);
    temp--;
    for (int j = 0; j <= temp; j++) {
      scanf("%lld", &x);
      x--;
      mcg[i] = min(mcg[i], cost[x]);
      s[stemp[x]] = i;
    }
  }
  string ma;
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> ma;
    ans += mcg[s[ma]];
  }
  cout << ans << endl;
  return 0;
}
