#include <bits/stdc++.h>
using namespace std;
const long long INF = 3000000000;
const long long MAX = 2007;
const long long ADD = 500107;
const long long MOD = 1000000007;
long long n, k, mm;
map<string, long long> m;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> k >> mm;
  string s[n];
  for (long long i = (0); i < (n); ++i) {
    cin >> s[i];
  }
  for (long long i = (0); i < (n); ++i) {
    long long a;
    cin >> a;
    m[s[i]] = a;
  }
  for (long long i = (0); i < (k); ++i) {
    long long x;
    cin >> x;
    long long mini = INF;
    vector<long long> temp;
    for (long long j = (0); j < (x); ++j) {
      long long yyy;
      cin >> yyy;
      temp.push_back(yyy);
      mini = min(mini, m[s[yyy - 1]]);
    }
    for (long long j = (0); j < (x); ++j) {
      m[s[temp[j] - 1]] = mini;
    }
  }
  long long sum = 0;
  for (long long i = (0); i < (mm); ++i) {
    string kkk;
    cin >> kkk;
    sum += m[kkk];
  }
  cout << sum;
}
