#include <bits/stdc++.h>
using namespace std;
map<string, int> id;
string s[100005];
char _s[32];
int c[100005], v[100005], g[100005];
int k, n, m;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    scanf("%s", _s);
    s[i] = string(_s);
    id[s[i]] = i;
  }
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) scanf("%d", c + i);
  for (int i = 0, ThxDem = k; i < ThxDem; ++i) {
    int q;
    scanf("%d", &q);
    v[i] = 1 << 30;
    while (q--) {
      int j;
      scanf("%d", &j);
      j--;
      v[i] = min(v[i], c[j]);
      g[j] = i;
    }
  }
  long long r = 0;
  for (int _ = 0, ThxDem = m; _ < ThxDem; ++_) {
    scanf("%s", _s);
    int i = id[string(_s)];
    r += v[g[i]];
  }
  printf("%lld\n", r);
  return 0;
}
