#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
unsigned long long mulmod(unsigned long long a, unsigned long long b,
                          unsigned long long m) {
  a = a % m;
  unsigned long long res = 0;
  while (b > 0) {
    if (b & 1) res = (res + a) % m;
    a = (a << 1) % m;
    b >>= 1;
  }
  return res;
}
unsigned long long power(unsigned long long a, unsigned long long b,
                         unsigned long long m) {
  if (b == 0) return 1;
  long long res = 1;
  while (b) {
    if (b & 1) res = mulmod(res, a, m);
    a = mulmod(a, a, m);
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool millerTest(unsigned long long n, unsigned long long d) {
  unsigned long long a = 2 + rand() % (n - 4);
  unsigned long long x = power(a, d, n);
  if (x == 1 || x == n - 1) return true;
  while (d != n - 1) {
    x = mulmod(x, x, n);
    d <<= 1;
    if (x == 1) return false;
    if (x == n - 1) return true;
  }
  return false;
}
bool isPrime(unsigned long long n, int k) {
  if (n == 2 || n == 3) return true;
  if ((n & 1) == 0) return false;
  if (n <= 1) return false;
  long long d = n - 1;
  while ((d & 1) == 0) d >>= 1;
  for (int i = 0; i < k; i++)
    if (!millerTest(n, d)) return false;
  return true;
}
map<string, int> dp;
int main() {
  ios::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, m;
  cin >> n >> k >> m;
  vector<string> strs;
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    strs.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    dp[strs[i]] = a;
  }
  for (int i = 0; i < k; i++) {
    int z;
    cin >> z;
    int mn = 1000000000;
    vector<int> p;
    for (int j = 0; j < z; j++) {
      int r;
      cin >> r;
      p.push_back(r);
      mn = min(mn, dp[strs[r - 1]]);
    }
    for (int i : p) {
      dp[strs[i - 1]] = mn;
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    string a;
    cin >> a;
    ans += dp[a];
  }
  cout << ans;
}
