#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
const int N = 100010;
map<string, int> p;
vector<int> v[100100];
;
int fa[N], w[N], mnw[N];
int main() {
  int n = read(), k = read(), m = read();
  string s;
  for (int i = 1; i <= n; ++i) {
    cin >> s;
    p[s] = i;
  }
  for (int i = 1; i <= n; ++i) w[i] = read();
  for (int i = 1; i <= k; ++i) {
    int x = read();
    while (x--) {
      int y = read();
      v[i].push_back(y);
      fa[y] = i;
    }
  }
  for (int i = 1; i <= k; ++i) {
    int x = v[i].size();
    mnw[i] = 1e9;
    for (int j = 0; j < x; ++j) mnw[i] = min(mnw[i], w[v[i][j]]);
  }
  long long ans = 0;
  for (int i = 1; i <= m; ++i) {
    cin >> s;
    int id = p[s];
    int x = fa[id];
    ans += mnw[x];
  }
  cout << ans;
  return 0;
}
