N,M,X = map(int,input().split()) d = {x:[] for x in range(1,M+1)} for i in range(N): A,B = map(int,input().split()) d[B].append(A) l = [] for k,v in d.items(): tmp = sorted(v) if tmp:tmp[-1]+=X l+=tmp l.sort(reverse=True) com = [0] for i in range(len(l)): com.append(com[i]+l[i]) K = int(input()) C = list(map(int,input().split())) ans = 0 for i in C: ans+=com[i] print(ans)