#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T = int>
inline T nxt() {
  char c = nc();
  T x = 0;
  int f = 1;
  for (; c > '9' || c < '0'; c = nc())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc())
    ;
  x *= f;
  return x;
}
const int N = 100123;
int a[N];
string s[N];
vector<int> group;
map<string, int> cost;
int main() {
  cin.sync_with_stdio(0);
  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 x;
    cin >> x;
    group.clear();
    for (int j = 0; j < (x); ++j) {
      int y;
      cin >> y;
      y--;
      group.push_back(y);
    }
    sort(group.begin(), group.end(),
         [&](int& x, int y) { return a[x] < a[y]; });
    int best_cost = a[group[0]];
    for (int j = 0; j < (x); ++j) cost[s[group[j]]] = best_cost;
  }
  long long ans = 0;
  for (int i = 0; i < (m); ++i) {
    string x;
    cin >> x;
    ans += cost[x];
  }
  cout << ans << '\n';
}
