from collections import defaultdict from itertools import accumulate N, M, X = map(int, input().split()) data = [] dic = defaultdict(list) for _ in range(N): a, b = map(int, input().split()) dic[b].append(a) for k, v in dic.items(): values = sorted(v, reverse=True) data.append(values[0]+X) for i in range(1, len(values)): data.append(values[i]) data.sort(reverse=True) data = list(accumulate(data)) K = int(input()) C = list(map(int, input().split())) ans = 0 for c in C: ans += data[c-1] print(ans)