#include <bits/stdc++.h>
using namespace std;
const int maxN = 500005;
const int maxK = 10005;
const int mod = (int)1e9 + 7;
const int inf = (int)1e9;
string s[maxN];
int c[maxN], mini[maxN], where[maxN];
unordered_map<string, int> mp;
int main() {
  memset(mini, -1, sizeof mini);
  int n, groups, m;
  cin >> n >> groups >> m;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    mp[s[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  for (int i = 0; i < groups; ++i) {
    int sz;
    scanf("%d", &sz);
    while (sz--) {
      int id;
      scanf("%d", &id);
      id--;
      where[id] = i;
      if (mini[i] == -1 || c[id] < mini[i]) {
        mini[i] = c[id];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    string word;
    cin >> word;
    int id = mp[word];
    ans += mini[where[id]];
  }
  cout << ans << endl;
  return 0;
}
