#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, ans[100005], h, x, mass[100005], sum, a[100005];
string b;
map<string, int> mp;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> b;
    mp[b] = i;
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= k; i++) {
    cin >> h;
    for (int j = 1; j <= h; j++) {
      cin >> x;
      mass[x] = i;
      if (j == 1)
        ans[i] = a[x];
      else
        ans[i] = min(ans[i], a[x]);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b;
    sum += (ans[mass[mp[b]]]);
  }
  cout << sum;
}
