import heapq N,M,X=map(int, input().split()) A=[] B=[] for i in range(N): a,b=map(int, input().split()) A.append(a) B.append(b) K=int(input()) C=list(map(int, input().split())) AB=list(zip(A,B)) AB=sorted(AB,key=lambda x:-x[0]) D=[[] for _ in range(M)] for i in range(N): D[AB[i][1]-1].append(AB[i][0]) D_now = [0 for _ in range(M)] E = [] for i in range(M): if len(D[i])!=0: E.append(-D[i][0]*1e10-i) heapq.heapify(E) used=set() ANS=[] while(len(E)!=0): e1_ = heapq.heappop(E) e1 = (-(int)((-e1_)//1e10),(int)((-e1_)%1e10)) F=[] e2=(1e10,-1) e2_=0 #print(e1) if e1[1] not in used: ANS.append((-e1[0],e1[1])) if e1[1]<0 or e1[1]>=M: print("break",e1) elif len(D[e1[1]])>D_now[e1[1]]+1: heapq.heappush(E, (-D[e1[1]][D_now[e1[1]]+1]*1e10-e1[1])) D_now[e1[1]]+=1 used.add(e1[1]) else: while(len(E)!=0): e_ = heapq.heappop(E) e=(-(int)((-e_)//1e10),(int)((-e_)%1e10)) if e[1] not in used: e2= e e2_=e_ break else: F.append(e_) if len(E)==0: break if e1[0]D_now[e1[1]]+1: heapq.heappush(E, (-D[e1[1]][D_now[e1[1]]+1]*1e10-e1[1])) D_now[e1[1]]+=1 if e2[0]!=1e10: F.append(e2_) else: ANS.append((-e2[0],e2[1])) used.add(e2[1]) if e2[1]<0 or e2[1]>=M: print("break",e2) elif len(D[e2[1]])>D_now[e2[1]]+1: heapq.heappush(E, (-D[e2[1]][D_now[e2[1]]+1]*1e10-e2[1])) D_now[e2[1]]+=1 F.append(e1_) for f in F: heapq.heappush(E, f) #print(ANS) ANS2=[0] used2=set() now=0 for i in range(N): if ANS[i][1] not in used2: used2.add(ANS[i][1]) now+=X+ANS[i][0] ANS2.append(now) else: now+=ANS[i][0] ANS2.append(now) ans=0 for k in range(K): ans+=ANS2[C[k]] print(ans)