import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;

void main()
{
	auto aaa = readln.chomp.split.map!(to!int);
	int n = aaa[0];
	int k = aaa[1];
	int m = aaa[2];
	string[] msg = readln.chomp.split;
	ulong[string] mapper;
	foreach (i, s; msg) {
		mapper[s] = i;
	}
	ulong[] cost = readln.chomp.split.map!(to!ulong).array;
	ulong[] best = new ulong[n];
	foreach (i; 0..k) {
		auto bbb = readln.chomp.split.map!(to!ulong);
		ulong x = bbb[0];
		ulong[] a = bbb[1..$].array;
		ulong ans = ulong.max;
		foreach (v; a) {
			ulong w = v - 1;
			ans = min(ans, cost[cast(uint)w]);
		}
		// stderr.writeln([x, ans]);
		foreach (v; a) {
			ulong w = v - 1;
			best[cast(uint)w] = ans;
			// stderr.writeln("\tbest : ", msg[w], " :", [w, ans]);
		}
	}
	string[] next = readln.chomp.split;
	ulong sum = 0;
	foreach (s; next) {
		sum += best[cast(uint)mapper[s]];
	}
	sum.writeln;
}
