import sys readline = sys.stdin.readline N, M, X = map(int, readline().split()) G = [[] for i in range(M)] A = [0] * N for i in range(N): A[i], B = map(int, readline().split()) G[B - 1].append((A[i], i)) for i in range(M): if G[i]: G[i].sort(reverse=True) A[G[i][0][1]] += X A.sort(reverse=True) Ac = [0] * (N + 1) for i in range(N): Ac[i + 1] = Ac[i] + A[i] K = int(readline()) C = list(map(int, readline().split())) ans = 0 for c in C: ans += Ac[c] print(ans)