#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  map<string, long long> mp;
  long long cost[n];
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s] = i;
  }
  for (long long i = 0; i < n; i++) {
    long long num;
    cin >> num;
    cost[i] = num;
  }
  for (long long i = 0; i < k; i++) {
    long long num;
    cin >> num;
    vector<long long> v;
    for (long long j = 0; j < num; j++) {
      long long x;
      cin >> x;
      v.push_back(x);
    }
    long long ans = 10000000000;
    for (auto d : v) {
      ans = min(ans, cost[d - 1]);
    }
    for (auto d : v) {
      cost[d - 1] = ans;
    }
  }
  long long a = 0;
  for (long long i = 0; i < m; i++) {
    string s;
    cin >> s;
    a = a + cost[mp[s]];
  }
  cout << a;
}
