#include <bits/stdc++.h>
using namespace std;
long long int dp[100009];
map<string, int> mp;
int main() {
  int n, k, m;
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    char s[30];
    scanf("%s", s);
    mp[s] = i + 1;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &dp[i]);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    long long mn = 1000000000;
    vector<int> t;
    for (int j = 0; j < x; j++) {
      int y;
      scanf("%d", &y);
      t.push_back(y);
      mn = min(mn, dp[y]);
    }
    for (int j = 0; j < x; j++) dp[t[j]] = mn;
  }
  long long ans1 = 0;
  for (int i = 0; i < m; i++) {
    char s[30];
    scanf("%s", s);
    ans1 += dp[mp[s]];
  }
  return !printf("%lld", ans1);
}
