#include using namespace std; using ll=long long; #define rep(i,n) for(ll i=0;i>N>>M>>X; vector> A(M); rep(i,N){ ll a,b; cin>>a>>b; A[b-1].push_back(a); } vector P; rep(i,M){ if(ll(A[i].size())==0)continue; sort(all(A[i])); reverse(all(A[i])); ll cnt=1; for(auto a:A[i]){ P.push_back(a+X*cnt); cnt=0; } } sort(all(P)); reverse(all(P)); vector PS(N+1,0); rep(i,N)PS[i+1]+=PS[i]+P[i]; ll an=0; ll K; cin>>K; rep(i,K){ ll c; cin>>c; an+=PS[c]; } cout<