#include <bits/stdc++.h>
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
long long gcd(long long x, long long y) { return (!y) ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return ((x / gcd(x, y)) * y); }
void file() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
map<string, int> d;
int arr[100005], cost[100005], group[100005];
int main() {
  file();
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    d[s] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    cost[i] = (1 << 30);
  }
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    while (x--) {
      int a;
      cin >> a;
      group[a] = i;
      cost[i] = min(cost[i], arr[a]);
    }
  }
  long long ans = 0;
  while (m--) {
    string s;
    cin >> s;
    ans += cost[group[d[s]]];
  }
  cout << ans;
  return 0;
}
