#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
long long a[1000005], n, cst[100005];
string s[100005];
map<string, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q, m, k, h, ans = 0, sum = 0, p, x, y;
  cin >> n >> k >> m;
  fill(&cst[0], &cst[100005], 1e17);
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1, x, y; i <= k; ++i) {
    for (cin >> x; x--; cst[i] = min(cst[i], a[y])) {
      cin >> y;
      mp[s[y]] = i;
    }
  }
  for (int i = 1; i <= m; ++i) {
    string t;
    cin >> t;
    ans += cst[mp[t]];
  }
  cout << ans;
}
