#include <bits/stdc++.h>
using namespace std;
long long cost[200005];
map<string, int> mp;
string second[200005];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> second[i];
    mp[second[i]] = i;
  }
  for (int i = 1; i <= n; ++i) cin >> cost[i];
  int x;
  while (k--) {
    cin >> x;
    int a[x + 1];
    long long mn = INT_MAX;
    for (int j = 1; j <= x; ++j) {
      cin >> a[j];
      mn = min(mn, cost[a[j]]);
    }
    for (int j = 1; j <= x; ++j) cost[a[j]] = mn;
  }
  long long c = 0;
  string p;
  for (int i = 0; i < m; ++i) {
    cin >> p;
    c += cost[mp[p]];
  }
  cout << c;
  return 0;
}
