#include <bits/stdc++.h>
using namespace std;
const long long oo = (1 << 30);
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<string> data(n);
  map<string, long long> reg;
  for (long long i = 0; i < n; i++) cin >> data[i], reg[data[i]] = i;
  vector<long long> cost(n);
  for (long long i = 0; i < n; i++) cin >> cost[i];
  vector<long long> ans(n);
  for (long long i = 0; i < k; i++) {
    set<long long> bus;
    long long x;
    cin >> x;
    long long mn = oo;
    for (long long j = 0; j < x; j++) {
      long long index;
      cin >> index;
      mn = min(mn, cost[--index]);
      bus.insert(index);
    }
    for (auto &it : bus) ans[it] = mn;
  }
  long long res = 0;
  for (long long i = 0; i < m; i++) {
    string s;
    cin >> s;
    res += ans[reg[s]];
  }
  cout << res << '\n';
  return 0;
}
