#include <bits/stdc++.h>
using namespace std;
int n, K, m;
string s[100005];
int a[100005], bel[100005];
map<string, int> ma;
vector<int> vs[100005];
bool cmp(const int &x, const int &y) { return a[x] < a[y]; }
long long ans;
int main() {
  scanf("%d%d%d", &n, &K, &m);
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    ma[s[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  int x, y;
  for (int i = 1; i <= K; ++i) {
    scanf("%d", &x);
    for (int j = 1; j <= x; ++j) {
      scanf("%d", &y);
      vs[i].push_back(y);
      bel[y] = i;
    }
    sort(vs[i].begin(), vs[i].end(), cmp);
  }
  string ss;
  for (int i = 1; i <= m; ++i) {
    cin >> ss;
    ans += (long long)a[vs[bel[ma[ss]]][0]];
  }
  printf("%I64d\n", ans);
  return 0;
}
