N,M,X = map(int,input().split()) C = {i:[] for i in range(1,M+1)} for _ in range(N): a,b = map(int,input().split()) C[b].append(a) for b in C: C[b] = sorted(C[b]) if len(C[b])>0: C[b][-1] = C[b][-1]+X A = [] for b in C: A += C[b] A = [0]+sorted(A,reverse=True) B = [0]*(N+1) for i in range(1,N+1): B[i] = B[i-1]+A[i] K = int(input()) D = list(map(int,input().split())) ans = 0 for i in range(K): ans += B[D[i]] print(ans)