#include <bits/stdc++.h>
using namespace std;
string s[100005], o[100005];
long long a[100005];
vector<vector<long long> > val;
map<string, int> me;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < k; ++i) {
    int c;
    cin >> c;
    vector<long long> t;
    for (int j = 0; j < c; ++j) {
      int w;
      cin >> w;
      me[s[w - 1]] = i;
      t.push_back(a[w - 1]);
    }
    val.push_back(t);
  }
  for (int i = 0; i < k; ++i) {
    sort(val[i].begin(), val[i].end());
  }
  long long sol = 0LL;
  for (int i = 0; i < m; ++i) {
    cin >> o[i];
    sol += val[me[o[i]]][0];
  }
  cout << sol << endl;
  return 0;
}
