#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m;
  int min;
  int number;
  int elem;
  long long res = 0;
  cin >> n >> k >> m;
  vector<int> cost(n);
  map<string, int> dict;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    dict[s] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
  }
  queue<int> Q;
  for (int i = 1; i <= k; i++) {
    cin >> number;
    min = 1000000009;
    for (int j = 1; j <= number; j++) {
      cin >> elem;
      elem--;
      Q.push(elem);
      if (cost[elem] < min) {
        min = cost[elem];
      }
    }
    for (int j = 1; j <= number; j++) {
      elem = Q.front();
      Q.pop();
      cost[elem] = min;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> s;
    res += cost[dict[s] - 1];
  }
  cout << res;
  return 0;
}
