n, m, x = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(n)] k = int(input()) C = list(map(int, input().split())) AB.sort(key=lambda x: x[0], reverse=True) seen = set() P = [] for i in range(n): a, b = AB[i] if b not in seen: seen.add(b) P.append(a + x) else: P.append(a) P.sort(reverse=True) accumP = [0 for _ in range(n + 1)] for i in range(n): accumP[i + 1] = accumP[i] + P[i] ans = 0 for i in range(k): ans += accumP[C[i]] print(ans)