#include <bits/stdc++.h>
using namespace std;
string s[100010];
long long int a[100010];
map<string, long long int> mm;
vector<long long int> v;
int main() {
  long long int n, k, m, x, y, min;
  cin >> n >> k >> m;
  for (long long int i = 0; i < n; i++) cin >> s[i];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < k; i++) {
    cin >> x;
    min = 1000000007;
    v.clear();
    while (x--) {
      cin >> y;
      v.push_back(y - 1);
      if (a[y - 1] < min) min = a[y - 1];
    }
    for (long long int j = 0; j < v.size(); j++) a[v[j]] = min;
  }
  for (long long int i = 0; i < n; i++) mm[s[i]] = a[i];
  long long int count = 0;
  string s1;
  for (long long int i = 0; i < m; i++) {
    cin >> s1;
    count += mm[s1];
  }
  cout << count << endl;
}
