#include <bits/stdc++.h>
using namespace std;
const int N = 100100, MOD = 1e9 + 7;
int start[N], cost[N], group[N];
vector<int> val(N, 1e9);
vector<int> g[N];
void dfs(int gr, vector<int>& arr) {
  for (auto nei : arr) {
    val[gr] = min(val[gr], cost[nei]);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  map<string, int> def;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    def[tmp] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
  }
  for (int i = 0; i < k; i++) {
    int t;
    cin >> t;
    for (int j = 0; j < t; j++) {
      int v;
      cin >> v;
      v--;
      group[v] = i;
      g[i].push_back(v);
    }
  }
  for (int i = 0; i < k; i++) {
    dfs(i, g[i]);
  }
  long long res = 0;
  for (int i = 0; i < m; i++) {
    string w;
    cin >> w;
    int num = def[w];
    res += val[group[num]];
  }
  cout << res;
}
